Monday, March 30, 2009

Adding UnitTests to CruiseControl

In this post I’ll describe how to add these tests to the Continuous Integration Server.  The process is very simple really, only a matter of a adding a new task in the Control Control Config Console (CCNETConfig) for that project.

Adding your Test to Continuous Integration

Assuming you have already added your UnitTest project and added it to the solution. Logon onto your build server and open CCNetConfig.  this is available from the start/all programs menu.

image

Click File/Open from the menu and browse to the servers configuration file (ccnet.config), which should be found in D:\Program Files\CruiseControl.NET\server folder on the local server and click Open.

Expand the project on which you have added the Unit tests and right click the Tasks node on the tree, in this case it’s MSS.

image

Choose Add Task and NUnitTask from the menu, you should then see the new node added to the tree.  Select this node and add the relevant information to the detail pane on the right.

image

(Assemblies) should point to the UnitTest DDL that is built during compilation.

Output File; should point to the logs folder on the build server

Path; points to the location of the NUnit Console application

timeout; Default to 100 seconds for timeout, however increase this for long running test projects.

Save your changes and you should be fine.

Viewing the results

Now every time the project builds your tests will be run against all the code.  This will highlight any places where the new code has adversely affected other areas of the solution.

image

From the CCNet control website (http://<server>/CCNet/) you can browse to your project and select “Latest Build” then select the “NUnit Details” link on the right of the screen.  Here you can see that 1 test was completed successfully.  Clicking the NUNIT Timings link will tell you how long it took to run the tests which have be very useful for performance testing.