Telerik blogs

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.

 failed-test

Requirements

The build agent should have the following:

  • Cassini.dll in the GAC
  • installed WebAii framework (adds browser plug-ins to IE and Firefox which make their automation possible)
  • the build service should run on an interactive port, under the user that performs the build

Usage

In the .proj file that you’re building, you should:

  • include the task:

        <UsingTask AssemblyFile="Telerik.MSBuildTasks.JsUnitTestRunner.dll" TaskName="RunJsUnitTests"/>
  • execute it

        <RunJsUnitTests TestProjectRoot="C:\BuildArtefacts\JsUnitTests\" WebServerPort="12345" Suite="Suite.aspx" Browsers="IE;FF">

            <Output TaskParameter="ExitCode" PropertyName="JsUnitTestResult" />

        </RunJsUnitTests>

The execution proceeds as follows:

  1. start a Cassini web server, which will host the directory C:\BuildArtefacts\JsUnitTests\ at http://localhost:12345
  2. use WebAii to automate a browser (in this case, Internet Explorer and Firefox) and auto-run the suite at http://localhost:12345/Suite.aspx
  3. log any failing tests

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.


Comments

Comments are disabled in preview mode.