Triage flaky tests end to end: detect and measure flakiness, quarantine without hiding signal, root-cause by cause category, and hold a flake budget. Use when CI is red for no reason, a test fails intermittently, or someone says "just re-run it".
./install.sh flaky-test-triagename: flaky_test_triage description: Triage flaky tests end to end: detect and measure flakiness, quarantine without hiding signal, root-cause by cause category, and hold a flake budget. Use when CI is red for no reason, a test fails intermittently, or someone says "just re-run it".
A flaky test is one that passes and fails on the same code. It is worse than a broken test, because a broken test tells you what to do while a flaky one teaches the team to ignore red builds. Martin Fowler's warning still holds: non-deterministic tests are "a virulent infection that can completely ruin your entire test suite." This skill is the field procedure: prove it is flakiness, get it out of the blocking path, fix the actual cause, and keep the suite honest over time.
Context for scale: Google's 2016 data showed about 1.5% of test runs reporting a flaky result, almost 16% of tests carrying some flakiness, and 84% of pass-to-fail transitions involving a flaky test rather than a real regression (John Micco, Google Testing Blog, May 2016).
A real regression fails consistently after a specific commit. Flakiness fails sporadically across commits, often correlating with CI load, time of day, or execution order rather than code changes.
pytest path/test_file.py::test_name --count 50 -x (pytest-repeat) is the standard hammer.Meta's useful framing: every real-world test is flaky to some degree; the question is how flaky. Treat it as a measurement, not a yes/no label. Common tiers practitioners use:
Thresholds are team-configured, not gospel. Pick numbers, write them down, revisit quarterly.
Quarantine is a state machine, not a flag: healthy -> quarantined -> (fixed -> healthy) or (stale -> deleted). The rule from Fowler: quarantine reduces the damage, "but you still have to fix them soon."
What quarantine does in CI: the test still runs, but its failure does not fail the build. It runs in a separate reporting lane so you keep collecting pass/fail data and can notice when a code change fixes it. Implementation patterns per ecosystem live in references/quarantine-recipes.md.
Guardrails (without these, quarantine becomes a graveyard):
Most flakiness falls into a few patterns. Classify before fixing; the fix direction follows the category. The full taxonomy with symptoms and fix recipes is in references/cause-taxonomy.md. The short version:
An intermittent failure can be a real production race condition, not test noise. Google's own warning on auto-quarantine: it "could easily mask a real race condition or some other bug in the code being tested." Investigate before dismissing.
A fix is not verified by one green run. Run the formerly flaky test at least 20 times in isolation and 20 times in the full suite. Both must be clean. If the flake was order-dependent, the suite runs matter more than the isolated ones.
Then release it from quarantine: remove the marker, delete the quarantine record row, close the ticket linking the fixing PR.
Set a cap on how much flakiness the suite is allowed to carry, e.g. under 2% of tests quarantined or flagged flaky at any time. Breaching the budget is a team priority, not a backlog item. Review the number on a cadence (weekly for active suites), and track the trend: whether the overall flakiness rate is rising or falling tells you if the effort is working.
Research notes and source URLs: ~/workspace/skill-production/scratch/flaky-test-triage-sources.md. Key references: John Micco, "Flaky Tests at Google and How We Mitigate Them" (Google Testing Blog, May 2016); Martin Fowler, "Eradicating Non-Determinism in Tests" (2011); Luo et al., "An Empirical Analysis of Flaky Tests" (FSE 2014); Meta Engineering, "Probabilistic Flakiness" (2020).
publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e
No ratings yet — be the first to rate it.