Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

The Flaky Test We Retried Instead of Fixing: What to Do Next

A green retry is another observation, not a repair. Find the conditions behind flaky test failures and restore a trustworthy regression signal.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A flaky test that fails and then passes on rerun has not been fixed. The green retry is a new observation, not proof that the test or the code is reliable. Use it as a clue, investigate the conditions behind the failure, and restore the test’s value as a regression signal.

What a flaky test tells you—and what it does not

Martin Fowler defines a non-deterministic test as one that “passes sometimes and fails sometimes, without any noticeable change in the code, tests, or environment.” (Martin Fowler, “Eradicating Non-Determinism in Tests,” first published April 14, 2011.) A failure followed by a pass is consistent with that pattern, but one retry alone does not establish the cause.

As an Amazon Associate I earn from qualifying purchases.

The practical problem is lost signal: when a regression test fails intermittently, it is harder to tell whether the code has a defect or the test is responding to variable conditions. Retrying until green can hide that uncertainty without explaining it. If a team grows accustomed to dismissing such failures, confidence in other test results can weaken as well.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Investigate the conditions that can change the result

Fowler identifies recurring sources of non-determinism. Treat these as leads to check, not as proof of what happened in a particular test:

  • Shared state or weak isolation: one test may leave data or process-wide state that affects another.
  • Asynchronous work checked with a fixed sleep: a guessed delay may be too short on a loaded machine and unnecessarily long when work finishes quickly.
  • Remote-service dependencies: network or service behavior can vary beyond the test’s control.
  • Direct use of the system clock: time-dependent behavior may change with the clock or with when the test runs.
  • Resource leaks: open resources or incomplete cleanup can affect later tests, especially in longer runs.

A repair-oriented workflow

  1. Record and reproduce the failure. Capture the failing test, relevant logs, and the conditions around the run. Compare code changes with variation in state, timing, machine load, and external dependencies. A successful rerun is useful data, but it does not replace this investigation.
  2. Control the starting state and isolate tests. Make setup predictable, and ensure a test cannot leave data or process-wide state that changes another test’s result.
  3. Wait for observable asynchronous behavior. Replace a fixed sleep with a wait for the condition the test actually needs, bounded by a timeout. This avoids relying on a guessed interval while preventing an indefinite wait.
  4. Make unstable dependencies controllable where appropriate. A test double can keep a remote service from making a test’s result depend on the network; validate the double’s contract separately. Inject a controllable clock for behavior that depends on time.
  5. Inspect teardown and resource cleanup. Look for resources that remain open or state that persists, particularly when failures appear after a long run or seem to move between tests.
  6. Contain only when necessary, and assign repair ownership. Fowler advises: “Place any non-deterministic test in a quarantined area. (But fix quarantined tests quickly.)” Quarantine can keep an unreliable test from disrupting immediate feedback, but it should have an owner and a prompt repair expectation rather than becoming a permanent destination.

Retry, quarantine, or fix?

These actions serve different purposes. A retry gathers another result; quarantine contains disruption; a repair addresses the source of the unreliable signal. Fowler’s guidance supports quarantine as temporary containment and prompt repair, but does not prescribe a retry count or a particular CI setting.

Action Effect on the regression signal Root cause Feedback and ownership
Retry A pass on rerun does not restore trust in the test; it is another observation. Does not, by itself, expose or fix the cause. Adds another run before a result; no repair owner or deadline is implied.
Quarantine Contains disruption from the test, but the test no longer provides normal regression coverage while quarantined. Does not fix the cause. Use temporarily, with an owner and prompt repair expectation.
Fix Can restore a trustworthy regression signal once the cause is addressed and the test behaves reliably. Targets the cause rather than masking it. Requires investigation and repair; the source does not specify a duration.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the guidance does—and does not—establish

Fowler’s article is engineering guidance, first published in 2011, not a new empirical study. It supplies no prevalence statistic, so there is no grounded percentage to attach to how often tests are flaky. It also does not establish what caused any particular failure or prescribe a universal retry policy. For further reading on test design, Fowler recommends Gerard Meszaros’s xUnit Test Patterns.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.