I am ideally after the simplest way to unit test my javascript via my Nant script, my ideal usage would be telling it where my src javascript files reside, then giving it another folder where all my test javascript files reside....
From my quick scout on the interwebs it seems that there are 2 layers to this, one being the actual testing library, then the other being the test runner.
As far as the actual testing library I would like it to be similar to N/JUnit, I know there is JSUnit but it doesnt seem like it can be used in the way I want, I did find a different version of JSUnit (1.3) which can be used with Ant, but it seemed to be an awful lot of work to get it put into Nant.
As far as the runner I dont care about it running things in the browser... I am using a MVP sort of approach to my src js code, so although the underlying view uses Jquery it would all be mocked out, so its not too much of an issue...
Any examples showing how I could hook it into Nant would be great!
Forgot this question was on here...
I ended up using JsTestDriver for my automated unit testing, I have plugged this into nant using:
<target name="javascript-tests" description="Run the Javascript test runner and test">
<exec program="${file.java}">
<arg line="-jar ${dir.tools}\js-test-driver\JsTestDriver-1.3.2.jar"/>
<arg line="--config ${dir.tools}\js-test-driver\JsTestDriver.conf"/>
<arg line="--port 4224"/>
<arg line='--browser "${file.firefox}"'/>
<arg line="--tests all"/>
</exec>
</target>
I faced an annoying issue, which was not documented anywhere and only happened to stumble across after asking some other questions, but it appears on the version I was using it would not work correctly with relative paths, but in the conf file I have the basepath variable which is token replaced by my build script:
# Server url
server: http://localhost:4224
# Base dir for relative lookups
basepath: D:\Code\myproject
load:
# Includes
That runs all my tests and tells me if they passed or failed, which is what I was after... I hope this gets someone else up and running quickly...