Inspired by the automation of functional tests with WebAii, I decided to bring our JsUnit tests on the same level as the NUnit ones – in the continuous integration build. As it turns out, automation with the WebAii framework was really easy – just a few lines were sufficient to integrate the test runner.
The build agent should have the following:
In the .proj file that you’re building, you should:
<UsingTask AssemblyFile="Telerik.MSBuildTasks.JsUnitTestRunner.dll" TaskName="RunJsUnitTests"/>
<RunJsUnitTests TestProjectRoot="C:\BuildArtefacts\JsUnitTests\" WebServerPort="12345" Suite="Suite.aspx" Browsers="IE;FF">
<Output TaskParameter="ExitCode" PropertyName="JsUnitTestResult" />
</RunJsUnitTests>
The execution proceeds as follows:
You can find the test project below. Please note that just building the web application will trigger the JsUnit test runner. It is advised that you make this the responsibility of the build agent. Also, debugging of this project is rather cumbersome, as MsBuild locks the task assembly – if you want to change something, see how to debug the custom task.