Search code examples
c#visual-studiounit-testingteamcitydotcover

Make TeamCity build fail if tests are not run


We have a setup where TeamCity builds the software and the runs the unit tests on it. We use a powershell script inspired by this answer, which runs the unit tests with vstest and reports code coverage with dotcover.

Sometimes, developers make changes that cause the script to not run tests at all. Instead of failing the build, TeamCity reports the build as successful, but doesn't mention tests (since they weren't run).

I would like to have the build fail if the tests are not run.

How do I accomplish this?


Solution

  • You can add build failure condition on metric change (see Build Failure Conditions step of build configuration administration area). There is metric called "number of tests". Set it to 0, to fail build if no tests ran.