TeamCity "Tests failed: N" build failure in CI
TeamCity parsed test results and found failing tests. By default a build with failed tests is marked failed. The build status shows the count and links each failed test with its output.
What this error means
The build status reads "Tests failed: N (M new)" and the Tests tab lists the failing tests with stack traces. The step itself may even exit zero if the runner does not propagate the code.
Tests failed: 3 (1 new), passed: 128, ignored: 2
Build failed: Tests failed: 3 (1 new)Common causes
Real test failures in the code
One or more tests assert incorrectly or throw, and TeamCity reports them via the test runner integration.
Flaky or environment-dependent tests
Tests that depend on timing, ordering, or external services fail intermittently only in CI.
How to fix it
Open the failed tests and fix the cause
- Go to the Tests tab and open each failed test to read its assertion and stack trace.
- Reproduce locally, fix the code or the test, and push.
- Confirm the build reports "Tests passed" on re-run.
Stabilize or mute flaky tests deliberately
For genuinely flaky tests, fix the nondeterminism, or mute the test in TeamCity so a known-flaky case does not block the pipeline while it is repaired.
How to prevent it
- Keep tests deterministic and independent of ordering and timing.
- Use TeamCity flaky-test detection to spot unstable tests.
- Mute rather than delete flaky tests so they stay tracked.