Skip to content
Latchkey

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.

TeamCity
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

  1. Go to the Tests tab and open each failed test to read its assertion and stack trace.
  2. Reproduce locally, fix the code or the test, and push.
  3. 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.

Frequently asked questions

What causes ""Tests failed: N""?
One or more tests assert incorrectly or throw, and TeamCity reports them via the test runner integration.
How do I fix "Tests failed: N"?
Open the failed tests and fix the cause

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card