Failed MSTest Build step, but Build process continues.

I have I build configuration where I basically execute the following steps

  • Cleanup
  • Build Solution
  • Run Tests (MSTest)
  • Publish

Every step is configured to execute "only if all previous steps finished sucessfully (zero exit code)

If some of my tests fail, in the project view I can see that the build is marked as failed, too.
However, the last step (Publish) is still executed, which is not what I want if test fail.

If I look in the build log, I can see Step 3/4 (the tests) is marked red, but the last line shows "Process exited with code 0" which is probably the reason.

Can I force Teamcity to not execute the next steps, if some tests fail?

I am using TeamCity Professional 8.0.3 (build 27540) and migrated recently from Teamcity 7. I am not sure about that, but I believe Teamcity 7 did this out of the box.

Comment actions Permalink

Update: It just tested a bit with mstest.exe and it looks like it is produces an exit code 0, if all tests pass and an exit code 1 with failed tests, so that should not be the problem.

In my Build Log I can see:

   Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit

I suppose, the NUnitLauncher plugin is also responsible of running mstests, however it looks like the exit code from mstest.exe is ignored.

Comment actions Permalink

Update II: I found a solution for this one.

If I change the "Execute Step" setting for every following build step to "Only if build status is successful" it works.


Please sign in to leave a comment.