There’s no clear, concise documentation on how to get NUnit working with CruiseControl.NET. So I figured I should write it, having gone through the pain of trying to figure everything out.
I assume you already:
- Have a solution that builds in CC.NET
- Have a project that builds the NUnit tests DLL
The recommended way of integration is not the nunit tag, but it’s via the exec tag. This supposedly will break less than using the nunit tag.
Here’s what you need to do:
Run NUnit in CruiseControl.NET
Add the following into your ccnet.config under tasks for your project:
<exec>
<executable>nunit-console.exe</executable>
<baseDirectory>C:\Program Files\NUnit 2.x.y.z\bin\net-2.0</baseDirectory>
<buildArgs>C:\blah\blah\your.nunit.dll /xml:C:\blah\blah\nunit-results.xml</buildArgs>
</exec>
After executing the main build (MSbuild or whatever it is), this will invoke nunit-console and tell it to run the your.nunit.dll assembly’s tests, and to write the output to C:\blah\blah\nunit-results.xml.
The next step is to tell CruiseControl.NET to read this file and include it in the dashboard information. To do this, we need to add a publisher. As a point of extensibility, CruiseControl.NET allows you to merge any XML files into the build report; some, like NUnit, which it understands, it will display meaningfully.
To add a publisher, add the following after your <tasks /> tag:
<publishers>
<merge>
<files>
<file>C:\blah\blah\nunit-results.xml</file>
</files>
</merge>
<xmllogger />
<statistics />
<modificationHistory onlyLogWhenChangesFound="true" />
</publishers>
This tells CruiseControl.NET to merge the C:\blah\blah\nunit-results.xml content into the main build XML.
And that should be it! Force a build, and you should see CC.NET reporting success/failure test statistics in the web dashboard.
Related posts: