views:

24

answers:

1

I have installed JsUnit and a test case as follows:

/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

When I open the test runner in a browser as a file, and test lineTestAbs.html from the jsunit/myTests directory, it passes. When I test the same file from the JavaScript directory, the test runner times out, asking if the file exists or is a test page.

Questions: Am I doing something wrong here, or is this the expected behavior? Is it possible to put test cases in a different directory structure, and if so what is the proper path reference to to JsUnitCore.js? Would JsUnit behave differently if the files were retrieved from an HTTP server?

<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>
A: 

A local file resource should be prefixed by file:// Drag jsUnitCore.js into your browser, then copy the url you get in the location bar back into your source.

dshaw
I can't drag the file into the browser. I can view it with file:///home/.../jsUnitCore.js. But when I put this in the src attribute, it still fails: src="file:///home/...jsUnitCore.js" does not work. Could this be a Ubuntu/IceWeasel issue?
chernevik
Can you access the file from an "Open File..." dialog?
dshaw