Flaky Test Reduction With DMAIC: Stop Reruns From Masking Unreliable Tests

Flaky Test Reduction With DMAIC: Stop Reruns From Masking Unreliable Tests

Reruns feel like progress. A test fails, the pipeline retries, the build turns green, and the team moves on. The failure never gets explained, and the same unreliable test quietly fails again next week.

This guide treats flaky tests as a process problem that also requires technical investigation. You will see how DMAIC organizes evidence, how controlled reruns help test hypotheses, and how stratification by environment and test order narrows possible causes. A quarantine policy with owners and expiry dates keeps unresolved failures visible.

Key Takeaways

  • Preserve first-failure evidence; a passing retry is not a repair.
  • Use DMAIC to define, investigate, verify, and monitor fixes.
  • Measure failure rate and flip rate separately.
  • Give quarantined tests owners, deadlines, and risk-based restoration criteria.
  • Report verified repairs separately from deletions and suppression.

How Can DMAIC Reduce Flaky Tests?

How Can DMAIC Reduce Flaky Tests?

DMAIC gives flaky test reduction a repeatable structure: Define, Measure, Analyze, Improve, and Control. These phases turn a vague complaint about pipeline noise into a reliability project with a baseline, owners, and measurable goals. Air Academy Associates' Lean Six Sigma online training explains this improvement framework.

Start with a written failure criterion: a flaky test can pass and fail without a relevant code change. As pytest's flaky test guidance explains, uncontrolled state, ordering, timing, or concurrency can affect outcomes. Pin the revision and record images, seeds, data, and dependencies to investigate variability; identical settings do not guarantee identical runtime conditions.

Do not assume that an intermittent failure is harmless. Google's analysis of flaky tests includes concurrency and other nondeterministic behavior in its causes, so investigate product code as well as test code and infrastructure.

  • Define: Write the flakiness criterion, the scope of suites covered, and who owns the response.
  • Measure: Capture failure rates, outcome transitions, retry counts, first-failure timestamps, and sample sizes.
  • Analyze: Stratify by environment, agent, test order, concurrency, and time of day before proposing fixes.
  • Improve: Change test design, isolation, and environment controls, then confirm with repeated runs on a fixed revision.
  • Control: Hold the gain with dashboards, review gates, quarantine expiry enforcement, and periodic audits.

For historical context, Google's May 2016 testing report said almost 16% of its tests showed some flakiness and about 1.5% of all test runs were flaky. These are different denominators, and neither figure is a current industry-wide failure rate.

Use your own baseline to decide where to focus: which tests fail intermittently, how much rerun time they consume, and what risk their failures could signal.

Before the workflow details, it helps to look at why reruns create such a convincing illusion of health.

Why Test Reruns Hide Nondeterministic Tests

Why Test Reruns Hide Nondeterministic Tests

Retries can help diagnose intermittent failures, but a passing retry is not proof of a repair. Playwright's documented retry behavior distinguishes tests that pass initially from those that fail and then pass on retry. Preserve that distinction in CI reporting.

If the green run replaces the red one in your reports, useful history can disappear. Keep the first failure's logs, seed, trace, and runner identity alongside the retry result.

1. Evidence Deletion

If a pipeline discards failed-attempt artifacts, investigators lose evidence about the original failure. Configure artifact retention for every attempt, not only the final successful run.

2. Silent Defect Masking

An intermittent failure may expose a product race condition, as the causes in Google's flaky test analysis illustrate. Retrying until green can leave that defect unresolved.

3. Distorted Reliability Metrics

Report first-attempt and post-retry pass rates separately, following the distinction in Playwright's test result categories. For example, a hypothetical 98% post-retry pass rate does not reveal how many builds needed retries.

4. Normalized Waiting

When retrying becomes the default response, teams may stop investigating recurring failures. Require a ticket or an existing incident reference for repeated unexplained failures.

5. Growing Quarantine Debt

A skip list can conceal unresolved tests indefinitely. Review disabled tests and record any coverage lost while they remain out of the blocking suite.

If you use retries, preserve the commit, environment image, seed, logs, traces, and first failure, then compare outcomes on the same revision. Keep ordinary pipeline results separate from targeted diagnostic reruns so the sampling method remains clear.

With the masking mechanism understood, the measurement phase becomes much more concrete.

Measuring Flip Rates and CI Pipeline Reliability

Define your metrics before collecting data. Here, failure rate means failed runs divided by total runs; flip rate means pass-to-fail or fail-to-pass transitions divided by the number of adjacent run pairs. They measure different things: a test that always fails has a zero flip rate, so zero flips alone cannot demonstrate reliability.

Choose repeat counts for the failure probability and confidence level you need to assess, rather than using 100 runs as a universal rule. Applying NIST's binomial confidence interval method, zero failures in 100 independent runs with a constant failure probability gives a one-sided 95% upper bound of about 3%, not proof that the probability is zero. Correlated runs or untested environments weaken that interpretation.

Metric What It Measures Why It Matters
Failure rate on fixed commit Failed runs divided by all runs under recorded conditions Estimates failure frequency for the sampled conditions
Flip rate on fixed commit Outcome transitions divided by adjacent run pairs Describes switching; does not rule out product defects
Rerun dependency rate Builds passing only after retry divided by all builds Reveals reliance on retries
First-attempt pass rate Runs passing initially divided by all first attempts Keeps retry outcomes from masking initial failures
Quarantine age per test Days since isolation, with maximum and distribution Highlights overdue investigations
Verified-repair share Confirmed repairs divided by closed investigations Separates repair from other closure decisions

Report quarantine age as a distribution, including its maximum and overdue entries, rather than relying only on the mean. An average can obscure a small number of long-abandoned tests.

Teams learning this measurement discipline can build it into a scoped improvement project. Air Academy Associates offers one-to-one project coaching support for project scoping and appropriate tool use; bring your pipeline baseline and investigation questions to that discussion.

Next, break down the measurements by operating conditions so the analysis can test specific explanations.

Analyzing Nondeterministic Tests by Environment and Order

Start with plausible causes and use the failure records to narrow them. Pytest's documented flakiness causes include shared state, ordering, timing, overly strict assertions, and thread-safety problems. Treat each pattern below as a hypothesis, not proof of causation.

  • Agent and container image: Check whether failures concentrate on particular runners; investigate resource limits and configuration differences.
  • Test execution order: Shuffle the suite and compare results for possible leaked state.
  • Concurrency level: Compare serial and parallel execution to investigate shared fixtures and data access.
  • Time and date: Check whether failures cluster around clock or calendar boundaries.
  • External dependencies: Record service responses and seeds, then test suspected sources of variability.
  • Data state: Compare clean setup with execution after suspected predecessor tests.

Verify the cause before changing anything. Reproduce the failure deliberately by forcing the suspected condition, then remove the condition and show the failure stops.

If the failure cannot be reproduced reliably, document the remaining uncertainty. Compare pre-change and post-change evidence across the conditions in which the failure originally appeared.

When several conditions may contribute, plan experiments that separate their effects.

Improving Test Design and Verifying Fixes

Improving Test Design and Verifying Fixes

Improvement work can involve parallelism, container memory, database isolation, and timeout settings. NIST's experimental design guidance describes factorial and fractional factorial designs for studying multiple factors; a reduced design may save runs, but can confound effects.

Treat each setting as a factor with defined levels, choose a suitable design, and measure failure rate for each combination. Plan replication and run order, and account for interactions and correlated outcomes when interpreting results.

  1. Pin the baseline. Use one revision for the diagnostic experiment and record its environment.
  2. Select factors. Choose a manageable set of suspected contributors and levels.
  3. Run the matrix. Plan repetitions, execution order, and failure-rate measurement for each combination.
  4. Identify drivers. Evaluate effects, interactions, and uncertainty before selecting a change.
  5. Apply the change. Record the patched revision and any fixture or environment changes.
  6. Confirm. Compare the patched revision with the baseline under representative and previously failing conditions, using a prespecified sample size and acceptance criterion.

Our Design of Experiments training develops experiment-planning and analysis skills. For flaky tests, adapt that framework to binary pass/fail outcomes and the conditions your pipeline actually encounters.

Confirmed fixes still need a policy for tests that cannot be repaired immediately.

Quarantine Age, Owners, and Restoration Criteria

Use quarantine as temporary isolation with explicit accountability. The following five items are a proposed operating policy, not a universal standard; tailor deadlines and approval rules to the risk of losing a blocking check.

  • Named owner: A person accountable for the investigation.
  • Remediation ticket: Linked, prioritized, and visible in the normal backlog.
  • Review deadline: Set a risk-based date; for example, a team might start with 14 days and require explicit approval for extensions.
  • Non-blocking lane: Keep the test running separately where feasible and record the coverage risk during isolation.
  • Restoration criteria: Require documented action, representative conditions, and a justified sample size and reliability threshold.

Publish quarantine age weekly with the oldest entries and accountable owners named. Escalate overdue work and document any extension.

Delete a test only after reviewing its purpose and coverage. Pytest's test deletion guidance recommends checking whether another test covers the functionality; otherwise, consider rewriting the test at a lower level.

Controlling Results and Separating Real Fixes From Suppression

Add a review gate requiring documented corrective action and planned verification before a quarantined test returns. Track first-attempt pass rates and retry dependence over time, keeping comparable suites and environments separate.

One useful local metric is a verified-repair share: confirmed repairs divided by all closed flaky-test investigations during the reporting period. Report justified deletions and unresolved suppressions separately, and keep skipped or retry-only cases open unless there is an explicit closure decision. This is a proposed management measure, not an established industry benchmark.

For ongoing monitoring, NIST's proportions control chart guidance provides a basis for tracking failure proportions when binomial assumptions are appropriate. Account for run volume, dependence, and changes in suite composition before interpreting control-chart signals; raw weekly counts alone can mislead.

AirAcad Resources for Investigating Test Reliability

AirAcad Resources for Investigating Test Reliability

These four offerings build skills relevant to the phases above, from structuring an investigation to monitoring results. They teach general improvement and statistical methods that QA and platform teams can adapt to pipeline data.

Lean Six Sigma Green Belt Online Course teaches the DMAIC framework, project definition, measurement, analysis, and control. Its self-paced modules can support a structured flakiness reduction project, with your test backlog as a potential application case.

Failure Mode and Effect Analysis (FMEA): risk analysis short course covers failure analysis and risk prioritization. Apply those skills to assess the consequences of missed defects and the adequacy of detection controls. Evaluate whether retry policies preserve evidence before assigning risk scores.

Validation Testing Short Course covers efficient test-combination planning, including all-pairs testing and sampling methods. Those skills can help select environment combinations for investigation. Combine configuration coverage with repeated-run evidence; a compact matrix alone does not establish that an intermittent failure has been eliminated.

Statistical Process Control Short Course teaches control-chart concepts, chart types, and signals requiring investigation. Apply the methods to suitable pipeline measures after checking their statistical assumptions. Use quarantine-age reports alongside those charts to track unresolved work.

Closing Thought

Reliable CI reporting keeps the first failure visible, verifies corrective action, and makes quarantine debt explicit. Use DMAIC to give that work a baseline, an owner, and a control plan so reruns do not become the definition of success.

Build your team's investigation and measurement skills with Air Academy Associates. Explore the training options above or discuss your project at info@airacad.com or 1-800-748-1277.

FAQs

What Makes an Automated Test Flaky?

A flaky test produces inconsistent pass/fail outcomes without a relevant code change. The causes described in Google's flaky test report include nondeterminism and infrastructure effects, so investigate the product, test, and environment rather than assuming a harmless test defect.

How Can DMAIC Identify Causes of Intermittent Test Failures?

Use DMAIC to define the problem and owner, measure first-attempt failures and controlled reruns, and analyze patterns by environment and test order. Then implement a targeted change and monitor for recurrence. This is an application of the framework described above, not a guarantee that every intermittent cause will be easy to reproduce.

When Should a Quarantined Test Be Restored to the Pipeline?

Restore a quarantined test after documented corrective action and a risk-based verification plan covering representative pipeline conditions. Apply NIST's binomial confidence interval guidance when interpreting repeated pass/fail results under its assumptions. A passing streak is evidence, not proof of zero future failures; retain monitoring and clear ownership.

Related Articles

Posted by
Air Academy Associates
Air Academy Associates is a leader in Six Sigma training and certification. Since the beginning of Six Sigma, we’ve played a role and trained the first Black Belts from Motorola. Our proven and powerful curriculum uses a “Keep It Simple Statistically” (KISS) approach. KISS means more power, not less. We develop Lean Six Sigma methodology practitioners who can use the tools and techniques to drive improvement and rapidly deliver business results.

How can we help you?

Name

— or Call us at —

1-800-748-1277

contact us for group pricing