Techment — Site Header

What is Flaky Tests

Definition

A flaky test is one that produces inconsistent results, sometimes passing and sometimes failing, without any change to the code, usually due to timing, shared state, or environmental dependencies, which erodes trust in the test suite if left unaddressed.
« Back to Glossary Index
  • Identifying flaky tests restores trust in the test suite’s signals
  • Fixing them removes false failures that waste engineering time
  • Addressing root causes exposes real timing and state bugs
  • Stabilising tests keeps CI pipelines reliable and unblocked

Real World Example

A CI build intermittently fails on the same test even though the code is unchanged; investigation reveals the test depends on a race condition with an external service, and fixing that dependency removes the flakiness.

FAQs

What causes flaky tests?

Common causes include timing and race conditions, shared or leftover state, network or environment dependencies, and non-deterministic logic.

Why are flaky tests harmful?

They erode trust in the suite, cause developers to ignore failures, and waste time re-running builds, masking real defects.

How are flaky tests handled?

By diagnosing and fixing the root cause, isolating state, removing nondeterminism, rather than simply retrying or disabling them long-term.

Hello popup window