FlakiMe: Laboratory-Controlled Test Flakiness Impact Assessment. A Case Study on Mutation Testing and Program Repair

Maxime Cordy, Renaud Rwemalika, Mike Papadakis, Mark HarmanarXiv 2019

Abstract

Test flakiness—where tests pass or fail unpredictably without code changes—introduces significant noise into software engineering research. This paper presents FlakiMe, a tool designed to inject controlled levels of non-deterministic failures into test suites to assess their impact on downstream tasks. Through case studies on mutation testing and automated program repair (APR), we demonstrate a "sensitivity gap." While mutation testing remains relatively robust, APR performance collapses even under minimal flakiness (1-5%), primarily due to the degradation of fault localization signals.

Introduction

In an ideal software development environment, test results are deterministic. However, real-world "flaky tests" often fail due to race conditions, network latency, or infrastructure instability. This unpredictability "poisons the well" for researchers developing tools for mutation testing or automated program repair. Without a systematic way to measure flakiness tolerance, it is difficult to determine if a tool's success is due to its algorithmic merit or mere environmental luck.

The FlakiMe Framework

To address this, we developed FlakiMe, a platform that extends the standard JUnit runner to seed controllable levels of flakiness. Instead of relying on hard-to-trigger "natural" flakiness, FlakiMe allows researchers to define a specific flakiness failure rate (e.g., a 5% probability that a passing test will be reported as a failure). This laboratory-controlled environment enables precise stress-testing of software engineering tools against varying degrees of noise.

Impact on Mutation Testing

We evaluated the impact of flakiness on mutation testing using the PIT tool. Mutation testing measures test suite quality by injecting small code errors ("mutants") and checking if the tests can detect them.

Our results show that mutation testing is surprisingly robust. As shown in the figure below, mutation scores ($\overline{MS}$) only shift by approximately 2% to 4% at a 5% flakiness rate. The noise introduced by flakiness is distributed somewhat evenly across the test suite, leading to a modest inflation of scores rather than a total breakdown of the metric.

Mutation score robustness across different projects as flakiness increases.

Impact on Automated Program Repair (APR)

In contrast to mutation testing, APR techniques—which use algorithms to automatically fix bugs—suffer "disastrous" consequences from flakiness. We tested two state-of-the-art tools: PRAPR (deterministic mutation-based) and ARJA (genetic programming-based) using the Defects4J benchmark.

The fragility of APR stems from its reliance on a chain of perfect signals. The first step, Fault Localization (FL), is particularly vulnerable; even 1% flakiness can cause FL precision and recall to drop by over 90%. Consequently, the repair tool begins searching for fixes in incorrect locations. As illustrated in the following figure, the number of valid patches generated drops precipitously as flakiness increases, with many bugs becoming unfixable at just 5% or 25% flakiness levels.

The impact of flakiness on the number of valid patches generated for various Defects4J bugs.

Discussion and Conclusion

The "sensitivity gap" identified in this study highlights a critical need for "flakiness-robust" software engineering tools. While some metrics like mutation scores can tolerate moderate noise, threshold-based activities like APR are easily derailed. Future work should focus on developing repair algorithms that can handle signal noise and incorporating project-specific knowledge to simulate more realistic, non-uniform flakiness distributions. FlakiMe provides the necessary infrastructure to benchmark these future improvements in a controlled, reproducible manner.

Summary updated

BibTeX
@misc{cordy2019flakime,
  author = {Maxime Cordy and Renaud Rwemalika and Mike Papadakis and Mark Harman},
  title = {{FlakiMe: Laboratory-Controlled Test Flakiness Impact Assessment. A Case Study on Mutation Testing and Program Repair}},
  year = {2019},
  eprint = {1912.03197},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.03197},
}
Figure