We use Jenkins for the continuous integration of .NET web applications with NAnt/NUnit for the .NET tests. Jenkins is configured with 9 slaves (all of which are Windows Server 2003) that runs many builds along with their automated tests.
We are trying to setup js-test-driver for running our JavaScript unit tests and the below NAnt task is working well locally on the developer workstations. Internet explorer is the only browser we would like to test on, as that is the only target browser for all our web applications.
<target name="jsTests" >
<echo message="Running JavaScript tests..." />
<exec program="java.exe">
<arg line="-jar '${jstestdriver.dir}\JsTestDriver.jar'" />
<arg line="--config '${ui.webtests.dir}\JsTestDriver.conf'" />
<arg line="--port 9876"/>
<arg line="--browser 'C:\program files\internet explorer\iexplore.exe'"/>
<arg line="--verbose"/>
<arg line="--reset"/>
<arg line="--tests all"/>
<arg line="--testOutput '${results.jstestdriver.dir}'"/>
</exec>
</target>
We are running into problems with the same task on Jenkins, probably because:
The GettingStarted
page on the js-test-driver wiki says we could run the browsers on a different machine than where the js-test-driver server is running:
Before you can run any of your tests you need to start the test server and capture at least one slave browser. The server does not have to reside on the machine where the test runner is, and the browsers themselves can be at different machines as well.
I've done something similar but no in a 100% windows setup, but I guess you wont have any problems doing something similar on Windows.
In my case, I had to test on more browsers: IE7, IE8, IE9, Chrome, Safari, Firefox 3.6 and latest versions, so, what I've done, was install virtual machines with all the browsers that I need, and another machine with jstestdriver running on server mode:
java -Xmx256m -jar JsTestDriver-1.3.4-a.jar --port 4224
All the virtual machines with the browsers, have always an instance of them pointing to that server (http://[jstd-server-ip]:4224/capture)
On those machines I have created a scheduled task, that resets the instance of the browsers every morning, because I've seen that some browsers, specially IE7 tends to stop working if it's running for more than 3 days.
taskkill /f /IM iexplore.exe
iexplore.exe http://[jstd-server-ip]:4224/capture
Those machines, and the jstestdriver server are running all the time. I'm not sure if in your case that's possible.
Then, on the applications, I'm using a maven plugin for launching tests: http://code.google.com/p/jstd-maven-plugin/wiki/GettingStarted that works better in my case, but if you are not using maven, I guess that in NAnt shoud be something like this:
<target name="jsTests" >
<echo message="Running JavaScript tests..." />
<exec program="java.exe">
<arg line="-jar '${jstestdriver.dir}\JsTestDriver.jar'" />
<arg line="--config '${ui.webtests.dir}\JsTestDriver.conf'" />
<arg line="--browser 'C:\program files\internet explorer\iexplore.exe'"/>
<arg line="--verbose"/>
<arg line="--reset"/>
<arg line="--tests all"/>
<arg line="--testOutput '${results.jstestdriver.dir}'"/>
</exec>
</target>
And in JsTestDriver.conf add this line on the top:
server: http://[jstd-server-ip]:4224
This tells your client instance of jstestdriver executed by jenkins to use http://[jstd-server-ip]:4224 as it's server.
Hope this helps you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With