The expensive kind of failure
A test that sometimes fails costs more than a test that always fails. A consistent failure gets triaged and fixed, or at least gets a bug filed against it. An intermittent one gets a rerun. The rerun comes back green, the build ships, and the next intermittent failure is met with another rerun. After a few rounds nobody reads the red anymore. The suite's signal decays long before the code does.
Martin Fowler put a figure on this dynamic in 2011, using an illustration rather than a survey: a hundred tests of which ten were non-deterministic were enough to make the suite fail often enough that people stopped treating the result as meaningful. He described non-deterministic tests as viral inside a suite. The count matters less than the effect on attention — a small minority of unreliable cases changes how a team reads every other result. The causes he listed were missing isolation, asynchronous behavior, remote services, time, and resource leaks. That is a classification drawn from experience, not a measured proportion.
Where the jitter enters
| Source of jitter | What it looks like in a run | What to inspect first |
|---|---|---|
| Random input | Generated values or shuffled collections change the path | The seed, the generator, and collection ordering |
| Clock and timeouts | Date math, fixed sleeps, or ordering by timestamp | Wall-clock reads and delays that assume a duration |
| Concurrency | Two cases collide on a port, a file, or a thread | Shared ports, shared fixtures, and parallel workers |
| Shared state | Rows or globals left by an earlier case change the outcome | Setup and teardown, and dependence on execution order |
| Remote services | A stub answers quickly once, slowly the next time | The external call and its retry policy |
Four of those rows — random input, time, concurrency, shared state — cover most cases that get labeled flaky. The fifth is Fowler's addition: a call that leaves the process behaves differently depending on the moment. Each category has a different repair, which is why one global retry policy is a poor substitute for diagnosis. Random input needs a recorded seed. Time needs an injected clock. Concurrency needs separation or serialization. Shared state needs teardown that actually runs.
Isolation comes first in Fowler's repairs; quarantine is second. He recommended moving unstable cases into a separate suite as a temporary measure, then removing them from it quickly. The temporary part is easy to miss. He suggested concrete ceilings — a cap around eight cases, or a week of residence — precisely because a separate suite with no ceiling becomes a place tests go to be forgotten. Quarantine stops the bleeding; it does not close the wound. A case that leaves the critical path takes any genuine race condition it contains out of view with it.
Retry buys silence and charges interest later
Google's testing blog described the mitigations in 2016: rerun failed tests, mark a test flaky so it reports failure only after several consecutive failures, and automatically quarantine high-flake tests out of the critical path. Each lowers noise. Each also carries a price. Under a consecutive-failure rule, a genuinely broken test can stay invisible far longer than its own runtime. An automatically quarantined test stops blocking builds, and a real defect can hide behind the same label meant to suppress a false alarm. The authors were candid about the human side: people habitually ignore alerts with a history of false positives. These are qualitative observations from one organization's own corpus, not a universal rate.
The distinction worth keeping is between lowering the false-alarm count and raising the true-signal count. Retry does the first. It changes which failures reach a human; it does not change why the test misbehaves. A suite can look calmer after a retry layer while its worst defect sits undiscovered in the cases that now never fail. That trade is acceptable only while the retries are buying time for a real fix.
What the studies actually support
Microsoft Research examined six large proprietary projects and reported that asynchronous calls were the leading source of flaky tests in that set. The same group built FaTB, a scheduler that balances flaky tests against time-sensitive ones, and evaluated it on five flaky tests. Running time fell by as much as 78 percent on those five tests. The paper is precise about what that means: the reduction was in execution time, and the study did not empirically show a change in how often the tests failed. It also found tests that developers believed they had fixed which still failed when checked again. Five tests at one company is a small base for a general claim.
A separate industrial study looked at CloudBuild and gathered thirty days of data across five projects. It defined a test as flaky when a failed run passed on rerun. One finding is a useful correction to intuition: a small number of distinct flaky tests and a large fraction of builds failing because of flaky tests are compatible observations. The authors note that the rerun definition cannot be guaranteed accurate and that the instrumentation used to collect the data adds runtime overhead, which can itself alter reproduction.
Google's later write-up observed that larger tests were more likely to flake. That observation deserves its limits stated alongside it. The size labels were chosen by engineers and could be stale, and the tools with high flake rates were concentrated in the larger tests. Size and tool choice travel together, so the observation supports correlation, not an instruction to avoid a particular tool or to treat test size as the cause.
Where verification can be reused
A shared runtime and an open catalog change one part of this problem: a behavior verified once can be exercised against several hosts without rebuilding the check for each one. That is a mechanism for reusing verification across surfaces. No first-hand flaky rate for mini-programs appears in the material reviewed, so none is claimed here. What carries over is the discipline — record the seed, control the clock, isolate the state, and give every quarantined case a deadline.