NUnit Extension Pack task stop after failed tests

270 Views Asked by At

I am running msbuild nunit task from extension pack that has 1 test which fails:

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

output:

enter image description here

How can I prevent the next target to be executed? "Zip-Projects" ? I am using MSBuild.Extension.Pack.March.2015.zip and framework 4.0

2

There are 2 best solutions below

0
nerlijma On BEST ANSWER

I solved it using an Error task and reading both output variables ResultErrors and ResultFailures.

<Error Condition="$(ResultErrors) > 0 Or $(ResultFailures) > 0" Text="Unit Tests didn't pass *****" />  
2
aolszowka On

You don't mention what version of the MSBuildExtensionPack you're using, but looking at the source for Trunk (Line 278) It looks like you need to specify The FailOnFailures Property in order to get their failure detection to work.

Therefore

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