A flaky test passes and fails without a relevant change to the product. Teams often respond with a retry, a longer wait or a comment that the test is "known flaky". Each workaround buys a little time and makes the suite a little less trustworthy.

At enterprise scale, flakiness becomes a decision problem. If the release gate is red, is the product broken or the test unstable? If nobody can answer quickly, the gate stops blocking anything meaningful.

Flakiness is usually systemic

The cause is rarely a single careless tester. Common sources include:

  • Asynchronous behaviour: the test checks too early or relies on a fixed delay.
  • Shared state: tests depend on data, order or sessions created by another test.
  • Environment drift: versions, configuration or dependencies differ between runs.
  • Test data: unique constraints, stale records or data consumed by parallel workers.
  • Selectors: locators bind to unstable markup or duplicate elements.
  • Resource contention: parallel execution saturates a shared service.
  • External dependencies: third-party services, email, queues or clocks behave inconsistently.

A retry hides the symptom. It does not tell the team which of these conditions caused the failure.

Detect flakiness before it becomes folklore

Reliable detection requires history. Track each test across runs and environments, with the product version, browser, worker, data set and failure message. A single rerun is not enough to classify a test as flaky.

Useful signals include pass/fail transitions without product changes, failures concentrated on specific workers or times, and tests that pass only after retry. A flakiness rate should be visible to the team that owns the test, not buried in a dashboard nobody checks.

Contain the blast radius

When a test is suspected flaky, move it to a quarantine suite rather than leaving it in the release gate. Quarantine is not a graveyard. It is a bounded state with an owner, a deadline and a requirement to investigate.

The quarantined suite should still run and report. The difference is that it does not block unrelated releases while the cause is being found. Without a deadline, quarantine becomes permanent technical debt.

Investigate the cause, not the last error

Start with evidence: screenshots, video, traces, network logs, application logs, environment details and the exact test data. Reproduce the failure in the smallest possible scope. Run it in isolation, then under parallel load, then with the original data.

Ask whether the test is waiting for the right condition. Is it asserting on a visual state that changes before the underlying operation completes? Is it sharing a login session? Is the selector matching a different element? Is the environment slower under load?

Fix the test or the system. A sleep is almost never the right fix; wait for a meaningful condition. A retry may be appropriate for a genuinely transient external dependency, but it should be an explicit, monitored policy rather than a blanket setting.

Prevent the next generation

  • Create unique data per test and clean up deterministically.
  • Use isolated browser contexts, users and tenants where possible.
  • Prefer stable, accessible locators over brittle CSS paths.
  • Design assertions around observable outcomes, not arbitrary timing.
  • Control clocks, randomness and external service mocks where appropriate.
  • Make parallel safety part of test review.
  • Version test data and environment configuration with the suite.

Make reliability a measured outcome

Track flake rate, mean time to classify a failure, quarantine age and the proportion of failures caused by the test system. Review the trend with the team. A rising flake rate is a signal to slow down and fix the foundation, not to add more retries.

Recognise that perfect determinism is not always possible. The goal is a suite whose failures are meaningful often enough that people still investigate them.

The takeaway

Flaky tests erode the credibility of automation. The fix is a reliability process: detect with history, contain with quarantine, investigate with evidence, repair the cause and measure the result.

A suite that occasionally fails for a known reason is manageable. A suite that fails for unknown reasons is not a release gate.

Build reliability into the execution layer

SuperSQE brings execution, evidence and test management together so flaky failures can be investigated rather than ignored.

Explore SuperSQE Automation Talk to Muyimeri