Reputation: 231
I am working setting up my continuous integration server using Teamcity and I have three steps for my build (.NET/VS2010/MSBUILD)
The issue I am trying to solve is to prevent step 3 from running if any of the test fail. Is this possible?
Upvotes: 4
Views: 1503
Reputation: 62484
You can do this using NUnit MsBuild Community task by handling Output parameter "ExitCode" and then executing MSBuild Error Task depends on "ExitCode" or execute Deploy task/targets depends on this condition, so it is up to you.
Error task:
Stops a build and logs an error based on an evaluated conditional statement. The Error task allows MSBuild projects issue error text to loggers and stop build execution
<!-- Build -->
<Build .... />
<!-- Run tests -->
<Nunit ....>
<Output TaskParameter="ExitCode"
PropertyName="NUnitResult" />
<!-- Stop build in case of error whilst tests run -->
<Error Text="Tests failed"
Code="$(NUnitResult)"
Condition="'$(NUnitResult)' != '0'"/>
<!-- Deploy -->
<Deploy Condition="'$(NUnitResult)' != '0'"/ ... />
Upvotes: 2