Flaky tests fail 1 in 5 runs and developers just click "re-run". How do you fix this culture and the tests?

BeginnerScenarioPipelines at scale
Answer

Situation read → Flaky tests train people to ignore red builds, and then real failures get ignored too.

What I'd do →

  1. Measure: track per-test pass/fail across runs to find the actual flaky ones (most CI tools or test reporters can do this).
  2. Quarantine: move known-flaky tests to a non-blocking job with an owner and a ticket, so main stays meaningful.
  3. Fix the common causes: shared state between tests, timing (sleep instead of waiting for a condition), test order dependence, real network calls, unseeded random data.
  4. Set a rule: quarantined tests must be fixed or deleted within two weeks.
  5. Publish a weekly flakiness report so it stays visible.

Why → A trustworthy red build is worth more than a large but unreliable test suite.

Interview tip → "Quarantine with an owner and a deadline" is the practical answer interviewers expect.

All Real-World Interview questions Roadmap: Interview readiness

More on Pipelines at scale