如何使用NAnt 0.86 beta运行NUnit v2.4.8测试?
时间:2020-03-05 18:48:05 来源:igfitidea点击:
我最近尝试使用NAnt(beta 0.86.2962.0)来运行一些使用NUnit的最新稳定版本(v2.4.8)编译的单元测试,但没有成功。
我得到的错误如下:
[nunit2]程序集" C:\ Dev \ MySample \ bin \ tests \ My.Sample.Tests.dll"不包含测试。
当然,程序集包含我可以从任何运行程序运行的测试,例如NUnit one,TestDriven或者Resharper。我想使用<nunit2>任务,而不是直接使用<exec>任务,但是我想知道是否仍然可能,甚至使用app.config文件来绑定程序集版本。
解决方案
回答
我不记得为什么,但是我放弃了使用<nunit2>任务,而我一直很高兴地使用<exec>任务和nunit-console.exe。如果有帮助,这是运行NUnit和FxCop的测试目标。请注意,如果可执行文件不在Windows路径中,它将跳过它们。
<target name="test" description="Run unit tests" depends="build"> <property name="windows-path" value="${string::to-lower(environment::get-variable('PATH'))}"/> <property name="nunit-in-path" value="${string::contains(windows-path, 'nunit')}"/> <echo message="Tests skipped because no NUnit folder was found in the Windows path." unless="${nunit-in-path}"/> <exec program="nunit-console.exe" if="${nunit-in-path}"> <arg file="../MyProject/MyProjectTest.nunit"/> </exec> <property name="fxcop-in-path" value="${string::contains(windows-path, 'fxcop')}"/> <echo message="FxCop skipped because no FxCop folder was found in the Windows path." unless="${fxcop-in-path}"/> <fxcop projectFile="../MyProject/MyProject.fxcop" directOutputToConsole="true" failOnAnalysisError="true" if="${fxcop-in-path}"/> </target>