If anyone is interested I've found a pretty good way to do some basic unit
testing on javascript files via looking at the dojo project's setup. It
doesn't close the test loop completely quite yet (there are ways to
completely simulate the browser but no one seems to be in agreement on how
to do it right now..though there are many implementations) , but it should
be sufficient to assert the basics.

It runs off of a java-friendly ant task using mozilla's rhino javascript
interpreter(new jar dependency). As an example, here is a snippet of a test
that checks the functionality of some date conversions:

function test_date_fromIso8601Date () {

//YYYY-MM-DD
var date = dojo.date.fromIso8601Date("2005-08-22");
jum.assertEquals("test1", 2005, date.getFullYear());
jum.assertEquals("test2", 7, date.getMonth());
jum.assertEquals("test3", 22, date.getDate());

//YYYYMMDD
var date = dojo.date.fromIso8601Date("20050822");
jum.assertEquals("test4", 2005, date.getFullYear());
jum.assertEquals("test5", 7, date.getMonth());
jum.assertEquals("test6", 22, date.getDate());

}

As you can see, assertions and all are there so it shouldn't take too much
imagination to get going with it. If this sounds like a nice addition (as
long as it's done right), I can create a patchdiff that adds all the project
mgmt integration stuff to get this task run, as well as one unit test for a
specific component, like the DatePicker (I can add an ant launch task to
your shared project runners if that would be desired as well. Don't know if
everyone has the ant view parked in their eclipse configuration) .

jesse

Reply via email to