SolveLang Blog · Testing
What is a flaky test?
Published
A flaky test is a test that produces different results on the same code: it fails, you re-run it with no change, and it passes. That is the whole definition, and it is stricter than it sounds — a test that fails because the code is broken is not flaky, and a test that fails because the environment changed is telling you something different. The flaky one fails because of something inside the test's own timing, ordering, or shared state.
How much flakiness is normal?
More than most teams expect. Google has reported that around 16% of its tests show some level of flakiness, and that roughly 84% of transitions from pass to fail involve a flaky test — figures from Google's own testing blog that are widely quoted because Google's test volume makes them hard to dismiss. At that scale, flakiness is not a discipline problem. It is a property of large test suites that has to be measured and managed.
The measurement that matters is the flip rate: how often a test changes result across runs on unchanged code. A flip rate above about 2% is a strong flakiness signal — the test is spending real CI time and real developer trust. Below that, a test may still be flaky, but the cost of hunting it usually exceeds the cost of living with it.
How to tell if a failure is flaky
The test is simple: re-run the exact same commit. If it passes with no code change, the failure was flaky by definition. GitHub Actions makes this visible — a job that succeeds on a later attempt shows run_attempt greater than 1, and a pattern of second-attempt greens across your history is a map of your flaky tests.
What not to do is treat 'probably flaky' as a diagnosis. A failure that repeats on the same commit is a real failure even if the test is also flaky sometimes. Flaky is a conclusion you reach from a green re-run on identical code, not a guess you make to keep the day moving.
Questions, answered briefly
Is a test that fails only in CI flaky?
Not necessarily. A test can fail deterministically in CI and pass deterministically locally because the environments differ — resources, versions, filesystem. That is an environment bug, not flakiness. Flaky means the same environment gives different answers on the same code.
Should flaky tests be deleted?
Quarantine first, with an expiry date: move the test out of the blocking path, keep it running and reported, and fix or delete it by the deadline. Deleting on sight loses whatever coverage the test was providing; leaving it in the gate teaches the team that red means nothing.