CC.Net and NUnit play nice together

This is a very quick post outlining what you need to do to get NUnit results displayed in your CC.Net results window. There are two steps for this, step one; configure your NAnt build script to call NUnit and step two; get the results merged in CC.Net.

Step 1:

Configure your NAnt build file to reference the NUnit framework and any test files you have in your project.

   17  <include name="Test\TestAnnex.cs"/>
   18         <include name="Test\TestDAL.cs"/>
   19         <include name="Test\TestHelper.cs"/>
   20       </sources>
   21       <references>
   22         <include name="Siberix.PDF.dll" />
   23         <include name="Siberix.Utils.dll" />
   24         <include name="nunit.framework.dll" />
   25       </references>
   26     </csc>
   27     <copy todir="nant_build">
   28       <fileset basedir=".">
   29         <include name="*.dll" />
   30       </fileset>
   31     </copy>
   32     <exec program="nunit-console.exe" 
   33           workingdir="D:\nant_build" 
   34           commandline="ReportsPdf.dll 
                             /xml:..\test_results\result.xml 
                             /nologo" />
   35   </target>

This will dump out the results to an xml file you specify. I have had to re-write the file paths and the commandline element so as to fit on the web page, but you get the idea.

Step 2:

Now configure you ccnet.config file to merge the resultant xml into the cc.net results. This is done within the publishers element.

   70 <publishers>
   71     <merge>
   72       <files>
   73         <file>
   74           <![CDATA[\test_results\result.xml]]>
   75         </file>
   76       </files>
   77     </merge>
   78     <xmllogger />
   79   </publishers>
   80   </project>

One thing you need to remember is to include the xmllogger element.

Like I said, quick post and not exactly anything new, but you (and I) can use it as an aide-mémoire.

No Comments