views:

150

answers:

1

I'm trying to run DOH from dojo-1.3.2 to test simple Javascript functions from command-line. However, I can't seem to get anything to run and the net seems to be devoid of DOH command-line documentation.

Ideally the structure I would like is:

Tests reside: C:\myproject\tests\

Dojo reside: C:\dojo-1.3.2\util\doh

As of right now I've put a simple test in ..\doh\tests

I try running while in the ..\doh directory:

java -jar ..\shrinksafe\js.jar runner.js testModule=tests.module

Each time I get:

js: uncaught JavaScript runtime exception: ReferenceError: "window" is not defin ed. An exception occurred: Error: Could not load 'tests.module'; last tried 'tests/module.js' 0 tests to run in 0 groups

Is there something I should be doing that I have left out? I've also tried pointing to the dojo.js file using dojoUrl= but still the same error.

As far as I can see my tests do not use window anywhere. I have three files:

tests/module.js

dojo.provide("tests.module");
dojo.require("tests.functions.functions");

tests/functions/functions.js

dojo.provide("tests.functions.functions");
dojo.require("tests.demoFunctions");

doh.register("tests.functions.functions", [
    function test_alwaysTrue(){
        doh.assertTrue(tests.demoFunctions.alwaysTrue());
    }
]);

tests/demoFunctions.js

    dojo.provide("tests.demoFunctions");

tests.demoFunctions.alwaysTrue = function(){
    return true;
};

I've also tried restructuring the directory to have ../dojo-1.3.2/ contain the tests. Running the same command as above from command-prompt fails identically. Dir Structure:

/dojo-1.3.2

   /dojo
   /tests
   ...
   /util

      /shrinksafe
      ...
      /doh
+1  A: 

Not sure where the 'window' is coming from, but I don't think doh ever worked properly with tests outside the Dojo directory. Does it work if you copy util/doh to be a peer of your tests directory?

peller
I've moved my /tests/... directory into util/doh/ and have run the same command "java -jar ..\shrinksafe\js.jar runner.js testModule=tests.module" and I still have the same issue. I've also tried an updated version of js.jar and the dojo-1.4.0 runner.js. Nothing had gotten better.
faust
Sorry, I have moved the /tests folder to be a peer (not child this time) of util/doh/ and it still fails
faust
ok, one more thing... try renaming your 'tests' directory and all the tests.* references to something else... I don't know where it is, but I think tests.* maps to dojo.* When you run the runner.js with its default dojo tests, it references them all as tests.* Dijit and DojoX tests don't do this. Sounds like something which needs to be cleaned up!
peller
I've renamed everything and still nothing. I have noticed that removing the 'testModule=....' parameters does cause DOH to look in the dojo.* dir though. As well, adding the parameter testUrl=..., the error output changes slightly to:...\util\doh>java -jar ..\shrinksafe\js.jar runner.js testUrl=tests\module.js testModule=tests.modulejs: uncaught JavaScript runtime exception: ReferenceError: "window" is not defined.js: "..\..\dojo\dojo.js", line 16: exception from uncaught JavaScript throw: Error: Could not load 'tests.functions.functions'; last tried '../tests/functions/functions.js'
faust
I took the files you listed above, put them in a peer directory called 'tests' and it failed. I renamed the directory to 'foo' along with all the tests.* -> foo.* and it worked.
peller
What was the exact command you used? "java -jar ..\shrinksafe\js.jar runner.js testModule=foo.module" ?Are you using dojo-1.3.2's version of DOH? I've moved and renamed everything like you've mentioned. Is it possible that it has something to do with my version of js.jar or runner.js?
faust
Updated both the js.jar and runner.js, and I still am having issues. I am at a loss now. Thank you for all the help it really is appreciated, do you know possibly anything else that might be preventing this from working?
faust
Everything works correctly now. Thank you very much. I believe that my current dojo-1.3.2 was incomplete or tampered from the original form. Once I reacquired dojo-1.4.0-src and ran the command everything was corrected. Thank you for all the help again! Final command used (for anyone stumbling upon this same issue and is lost):testFolder should be stored in your dojo-release-x.x.x\ directory and the command-line operation "java -jar ..\shrinksafe\js.jar runner.js testModule=testFolder.moduleName"You may need to download the shrinksafe (or rhino) folder seperately then add it to .../util/
faust
Great. Glad you finally got it to work. Still, there are at least two problems here: one, that you need to co-locate Dojo and your tests (there's an open ticket on this) and two, you can't call it "tests" (probably should open a ticket on this also)
peller