Search code examples
visual-studio-2008unit-testingnant

Automatic Unit Testing with NANT and VS2008 during build process


I'm using VS2008 Pro and as such my c# project includes a bunch of Unit Tests written in the MS bundled unit test framework (sorry I have no idea what its official name is!). I would like to be able to run these unit tests as part of my build process.

Is it possible to get Nant to automatically run these Unit tests during a build?


Solution

  • The solution that worked for me is the following:

    <exec program ="C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe" >
        <arg value="/testcontainer:${Test_dll}"/>
        <arg value="/resultsfile:C:\Test\TestResults.trx"/>
    </exec>
    

    This is just the basic nant element, although it is as extensible as the MSTest command line will allow.