我从扩展包中运行msbuild nunit任务,其中有1个测试失败:
<Target Name="Tests">
<MSBuild.ExtensionPack.CodeQuality.NUnit
Assemblies="$(DropsDir)\$(Configuration)\$(TestPrj)\$(TestPrj).dll"
ToolPath="$(NUnitPath)"
ContinueOnError="False">
<Output TaskParameter="Total" PropertyName="ResultTotal"/>
<Output TaskParameter="NotRun" PropertyName="ResultNotRun"/>
<Output TaskParameter="Failures" PropertyName="ResultFailures"/>
<Output TaskParameter="Errors" PropertyName="ResultErrors"/>
<Output TaskParameter="Inconclusive" PropertyName="ResultInconclusive"/>
<Output TaskParameter="Ignored" PropertyName="ResultIgnored"/>
<Output TaskParameter="Skipped" PropertyName="ResultSkipped"/>
<Output TaskParameter="Invalid" PropertyName="ResultInvalid"/>
</MSBuild.ExtensionPack.CodeQuality.NUnit>
</Target>
输出:
如何防止下一个目标被执行? &#34;拉链项目&#34; ? 我正在使用MSBuild.Extension.Pack.March.2015.zip和framework 4.0
答案 0 :(得分:1)
我使用Error任务解决了它并读取了输出变量ResultErrors和ResultFailures。
<Error Condition="$(ResultErrors) > 0 Or $(ResultFailures) > 0" Text="Unit Tests didn't pass *****" />
答案 1 :(得分:0)
您没有提及您正在使用的MSBuildExtensionPack版本,但查看Trunk的来源(第278行)看起来您需要指定FailOnFailures
财产,以使他们的故障检测工作。
因此
<Target Name="Tests">
<MSBuild.ExtensionPack.CodeQuality.NUnit
Assemblies="$(DropsDir)\$(Configuration)\$(TestPrj)\$(TestPrj).dll"
ToolPath="$(NUnitPath)"
FailOnFailures="True"
ContinueOnError="False">
<Output TaskParameter="Total" PropertyName="ResultTotal"/>
<Output TaskParameter="NotRun" PropertyName="ResultNotRun"/>
<Output TaskParameter="Failures" PropertyName="ResultFailures"/>
<Output TaskParameter="Errors" PropertyName="ResultErrors"/>
<Output TaskParameter="Inconclusive" PropertyName="ResultInconclusive"/>
<Output TaskParameter="Ignored" PropertyName="ResultIgnored"/>
<Output TaskParameter="Skipped" PropertyName="ResultSkipped"/>
<Output TaskParameter="Invalid" PropertyName="ResultInvalid"/>
</MSBuild.ExtensionPack.CodeQuality.NUnit>
</Target>