测试失败后,NUnit Extension Pack任务停止

时间:2015-07-10 19:55:28

标签: msbuild msbuild-task msbuild-4.0 msbuildextensionpack

我从扩展包中运行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>

输出:

enter image description here

如何防止下一个目标被执行? &#34;拉链项目&#34; ? 我正在使用MSBuild.Extension.Pack.March.2015.zip和framework 4.0

2 个答案:

答案 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>