【发布时间】:2010-09-28 03:36:02
【问题描述】:
我正在修改一个 Nant 构建脚本来运行一些单元测试。对于本地运行的测试和要在团队城市运行的测试,我有不同的目标。
<target name="run-unit-tests">
<property name="test.executable" value="tools\nunit\nunit-console.exe"/>
<call target="do-unit-tests"/>
</target>
<target name="run-unit-tests-teamcity">
<property name="test.executable" value="${teamcity.dotnet.nunitlauncher}"/>
<call target="do-unit-tests"/>
</target>
在目标 do-unit-tests 我通过设置属性并调用 NCover 执行代码覆盖运行来设置运行哪些测试程序集,如下所示:
<target name="do-unit-test">
<property name="test.assemblies" value="MyProject.dll">
<call target="do-unit-test-coverage" />
</target>
<target name="do-unit-test-coverage">
<ncover <!--snip -->
commandLineArgs="${test.args}"
<!--snip-->
</ncover>
</target>
正如您在 ncover 部分中看到的,我需要一个名为 "test.args" 的属性。此属性取决于 "test.assemblies"
即:<property name="test.args" value="${test.assemblies} <!--snip -->" />
test.args 需要在本地运行的单元测试和团队城市中的单元测试之间进行不同的设置...所以我试图弄清楚如何设置它。 p>
如果我将 test.args 的属性放在属性“test.assemblies”之后的“do-unit-test”中,如果 run-unit- 调用 do-unit-test,我就无法指定一个 test.args测试和另一个用于 run-unit-tests-teamcity。
我一直在尝试在“do-unit-test”中执行以下操作:
<if test="${target::exists('run-unit-tests-teamcity')}">
<property name="test.args" value="..." />
</if>
但显然这不起作用,因为目标永远存在。
然后我想测试我当前的目标 do-unit-test 是否已被 run-unit-tests-teamcity
调用这可能吗?我在 Nant 文档中看不到它?由于它不存在,这要么意味着它将成为未来的一个功能,要么我不了解 Nant 构建脚本中的内容是如何指定的。
【问题讨论】:
标签: configuration nant build-script