开发者

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?


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.


It is calld MSTest. You could just use the exec task to call the executable directly:

(Correct for an old version of NAnt but apparently not any more. See the accepted answer).

<exec>
    <executable>%VS_INSTALL%\Common7\IDE\MSTest.exe</executable>
    <baseDirectory>PPRJECT LOCATION</baseDirectory>
    <buildArgs>/testcontainer:TestDLLs /runconfig:localtestrun.Testrunconfig /resultsfile:testResults.trx</buildArgs>
    <buildTimeoutSeconds>600</buildTimeoutSeconds>
</exec>

I am surprised it does not come with a task built in.

For reference here is a list of MSTest Command-Line options.

NB: these options are for VS2010, it is possible to view the Command-Line options from other VS versions by selecting the correct version on the page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜