Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TeamCity - Stop build when a test fails

Is it possible to stop a TeamCity build (the entire build, i.e. it won't execute subsequent steps) when a unit test fails? Ideally I'd also like it to terminate the currently executing step which in my case would be the Nunit Test Runner. In my circumstance there is no point in continuing the build if a single unit test fails. I've looked at Failure Conditions but I don't think they are applicable as the build continues to run.

Feature requested: http://youtrack.jetbrains.com/issue/YTF-3275

like image 565
Mark Walsh Avatar asked Jul 30 '13 16:07

Mark Walsh


People also ask

How do you mute a TeamCity test?

Assigning Investigations of Build Problems and Failed Tests Navigate to the Overview tab of the Build Results page (or the Current Problems tab of the Project Home), click the arrow next to the build problem, and then click Investigate/Mute.

How do I manually trigger a build in TeamCity?

To run a custom build with specific changes, open the build results page, go to the Changes tab, expand the required change, click the Run build with this change, and proceed with the options in the Run Custom Build dialog. Use HTTP request or REST API request to TeamCity to trigger a build.


2 Answers

As you noted, TeamCity can run no further build steps on test failures in NUnit tests with "Only if build status is successful" step execution condition. However, that does not make the tests run stop until the step finish.

A related feature request is TW-23766.

The only workaround I can consider currently is not to use NUnit test runner and implement the logic inside the build script. For example, with nunit-console.exe like Manuel noted. If you choose to follow this route, consider using TeamCity Addin for NUNit.

like image 141
Yaegor Avatar answered Nov 12 '22 01:11

Yaegor


You can do it using nunit-console.exe. accordingly to the official documentation (http://nunit.org/index.php?p=consoleCommandLine&r=2.6.2) it provides a /stoponerror switch that does exactly what you need.

it can also generate an XML output that can be parsed by teamcity (there is a build feature for that) in order to populate the "test" tab.

like image 44
Manuel Spezzani Avatar answered Nov 11 '22 23:11

Manuel Spezzani