开发者

NAnt script for running multiple test assemblies

I'm just getting into TDD, and from looking around, the general concensis seems to be to have a one to one mapping from a code project to a test project. My question is, if 开发者_运维百科you follow this route, and have multiple test assemblies, what is the best way to run these as part of an NAnt script? If it makes a difference, I am using NUnit as my testing framework.


You can create a "test project" via the NUnit GUI, and save it to a file. In the GUI, you can add to the project the test dlls, which in turn reference the ones under test.

You can then pass that file to the NUnit console from within NAnt. e.g.

<property name="nunit.output" value="${dir.reports.nunit}\nunit-results.xml" />
<property name="nunit.input" value="proj.nunit" />

<exec program="${dir.tools}\nunit\bin\nunit-console.exe" failonerror="true">
    <arg value="${nunit.input}" />
    <arg value="/xml:${nunit.output}" />
</exec>

This way, NAnt need not know about the test dlls, just the NUnit project that contains that information.


I'd suggest the best way to go about this is to compile both projects from NAnt individually using the CSC command referencing each project file (csproj) rather than the solution. Then use the nunit-console command (as a separate Nant task) to execute your tests.

Whether you have one build large script/file that does this or separate separate ones for each project or task is up to you (or how complex your projects are).

The way I have my team's builds set up is that I have one 'master' build script which calls into other build scripts to perform specific tasks. For example 'master' calls 'compile' and then 'test' (passing in the results of the 'compile' script appropriately). This way the compilation of my core project is separated from the automated testing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜