我已经安装了 JsUnit 和一个测试用例,如下所示:
/home/chernevik/Programming/JavaScript/jsunit
/home/chernevik/Programming/JavaScript/jsunit/testRunner.html
/home/chernevik/Programming/JavaScript/jsunit/myTests/lineTestAbs.html
/home/chernevik/Programming/JavaScript/lineTestAbs.html
当我在浏览器中将测试运行程序作为文件打开并从 jsunit/myTests 目录测试 lineTestAbs.html 时,它通过了。当我从 JavaScript 目录测试同一个文件时,测试运行程序超时,询问该文件是否存在或者是一个测试页面。
问题:我在这里做错了什么,还是这是预期的行为?是否可以将测试用例放在不同的目录结构中,如果可以,对 JsUnitCore.js 的正确路径引用是什么?如果从 HTTP 服务器检索文件,JsUnit 的行为会有所不同吗?
<html>
<head>
<title>Test Page line(m, x, b)</title>
<script language="JavaScript" src="/home/chernevik/Programming/JavaScript/jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript">
function line(m, x, b) {
return m*x + b;
}
function testCalculationIsValid() {
assertEquals("zero intercept", 10, line(5, 2, 0));
assertEquals("zero slope", 5, line(0, 2, 5));
assertEquals("at x = 10", 25, line(2, 10, 5));
}
</script>
</head>
<body>
This pages tests line(m, x, b).
</body>
</html>