views:

75

answers:

2

is it possible for ccnet to say that the build has failed in the ccnet tray and the web site if a unit test fails for the project?

Anyone know of a tutorial for this?

A: 

Of course ! And it is the goal for continuous integration !

Just add a task to run your unit test after compilation. It depends heavily on the programming language you use, but you can consider running the EXE for unit tests.

So to summarize, sample task order :

  • Get source from version control
  • Compile source
  • Compile tests
  • Run tests
  • Report

You ask for a tutorial, I can give you an example :

  <!-- SVN implementation -->
  <sourcecontrol type="svn">
    <trunkUrl>http://dephicodetodoc.svn.sourceforge.net/svnroot/dephicodetodoc/trunk/DelphiCodeToDoc/&lt;/trunkUrl&gt;
    <workingDirectory>$(WorkingBaseDir)\DelphiCodeToDoc</workingDirectory>
  </sourcecontrol>

  <!-- Build tasks to implement -->
  <tasks>
    <!-- Compile main application -->
    <msbuild>
      <executable>$(MSBuildPath)\MSBuild.exe</executable>
      <workingDirectory>$(WorkingBaseDir)\DelphiCodeToDoc\Source</workingDirectory>
      <projectFile>DelphiCodeToDoc.dproj</projectFile>
      <buildArgs>/target:Build /p:Config=Debug</buildArgs>
    </msbuild>

    <!-- Compile tests -->
    <msbuild>
      <executable>$(MSBuildPath)\MSBuild.exe</executable>
      <workingDirectory>$(WorkingBaseDir)\DelphiCodeToDoc\Test</workingDirectory>
      <projectFile>DelphiCodeToDoc_Tests.dproj</projectFile>
      <buildArgs>/target:Build /p:Config=XmlOutput</buildArgs>
    </msbuild>

    <!-- Execute unit tests -->
    <exec>
      <executable>$(WorkingBaseDir)\DelphiCodeToDoc\Exe\DelphiCodeToDoc_Tests.exe</executable>
      <baseDirectory>$(WorkingBaseDir)\DelphiCodeToDoc\Exe\</baseDirectory>
    </exec>
TridenT
+2  A: 

This is the good tutorial how to set up CCNET with NUnit: http://ilmatte.wordpress.com/2008/06/01/cruisecontrolnet-tutorial-part-1/

Continuous integration allows to do even more interesting things. For example check code style with StyleCop, look for obvious bugs with FxCop, track dependencies with NDepend, automatically deploy application on staging server for manual testing, perform acceptance testing through UI, do performance testing etc

Yauheni Sivukha