Automating MbUnit With CruiseControl.NET

Cruise Control.NET (CCNET) is an automated continuous integration server for the .NET platform. Every time a developer commits a new set of modifications, the server will automatically run a build script to validate the changes. The script typically performs this validation by building the code and running unit tests against it, such as those written with MbUnit. CCNET is freely available from http://confluence.public.thoughtworks.org/display/CCNET.

The build script run by CCNET can be written for either nAnt or MSBuild. As long as you can get the scripts working outside of it, CCNET will be able to run them too. The only other issue to prevent MbUnit integrating seamlessly with CCNET is the test report. By default, to see the test run report generated by MbUnit from within CCNET, you will need MbUnit to generate an XML report in your script and then apply a specific XSL stylesheet to it to match the format CCNET requires. (The default stylesheet in CCNET works only with nUnit reports.)

This is achieved as follows.

  1. Make sure MbUnit is generating an XML report in your build script
  2. Open the CCNET Server config file (installed by default at %ProgramFiles%\CruiseControl.NET\server\ccnet.config) and add the report into CCNET’s results using the file merge task.
    <tasks>
       <merge>
          <files>
             <!-- Add your mbunit report file as follows -->
             <file>c:\path\to\mbunit-report.xml</file>
          </files>
       </merge>
    </tasks>
    
  3. Switch the nUnit XSL stylesheets used in CCNET by default to the MbUnit stylesheets. There are two ways to do this

Note that the MbUnit stylesheets that ship with CCNet do have a slight bug, refer to this JIRA report for the fix