Mutation Testing in Evolving Systems: Studying the relevance of mutants to code evolution

Milos Ojdanic, Ezekiel Soremekun, Renzo Degiovanni, Mike Papadakis, Yves Le TraonACM Trans. Softw. Eng. Methodol 2021 · DOI

TL;DR

As software evolves, testing becomes more complex. This paper introduces "commit-aware mutation testing" to focus testing efforts on mutants relevant to recent code changes. Their extensive study reveals that most relevant mutants lie outside the changed code, highlighting the need to test interactions between new and existing code, and demonstrating significant efficiency gains over traditional methods.

What Problem Does This Paper Address?

Software systems are rarely static; they evolve through frequent code modifications (commits) to fix bugs, add features, or refactor. This evolution necessitates regression testing to ensure new changes don't break existing functionality. Traditional mutation testing, a powerful technique for assessing test suite effectiveness by injecting artificial faults (mutants), becomes challenging in evolving systems. The sheer volume of mutants generated for the entire codebase can be overwhelming and costly.

The core problem this paper addresses is how to make mutation testing more efficient and effective for evolving software. Specifically, it tackles the challenge of identifying "commit-relevant mutants" – those mutants whose behavior is influenced by or influences the recent code changes. The authors aim to understand the characteristics of these mutants, their location, and how to best leverage them to reduce testing effort without sacrificing fault detection capabilities.

Methods

The paper proposes and employs a novel approach to identify "commit-relevant mutants" using higher-order mutants (HOM) and an observational slicing concept. Instead of just looking at mutants within the changed code, they generate second-order mutants by combining a mutant within the changed code with a mutant outside the changed code. If the behavior of this combined mutant differs from the behavior of the individual mutants, it indicates an interaction, and the mutant outside the change is deemed "commit-relevant." This approach allows them to capture dependencies between changed and unchanged code.

They also introduce a commit-aware mutation testing framework that leverages this HOM-based approach. The core algorithm involves generating first-order mutants within and around the change, creating higher-order mutants, and then comparing their assertion outputs to identify relevant ones. They also investigate subsumption relations among mutants, where one mutant's test requirements are covered by another, to further reduce the mutant set.

Datasets

The study uses a dataset of 288 commits from five mature open-source Java projects: commons-collections, commons-io, commons-text, commons-csv, and commons-lang. These projects were selected for their size, history, and use of JUnit4 for testing. The experiments involved generating over 9.7 million higher-order mutants and over 260,000 first-order mutants.

Key Insights and Ideas

  • Most relevant mutants are outside the change: This is a crucial finding. The authors demonstrate that a significant majority (81%) of commit-relevant mutants are located in code not directly modified by the commit. This underscores the importance of testing how new code interacts with existing code, not just the new code itself.
  • Commit-aware mutation testing offers substantial cost reduction: By focusing on commit-relevant mutants, the number of mutants to analyze can be reduced by up to 93%. This translates to significant savings in computational effort and manual analysis.
  • Predicting commit-relevant mutants is hard: Simple proxy variables like commit size, mutant type, or the number of mutants within a change do not reliably predict commit-relevant mutants. This suggests a need for more sophisticated techniques.
  • Subsuming mutants offer further optimization: Identifying subsuming commit-relevant mutants can reduce the mutant set even further, leading to even greater efficiency gains.
  • Traditional mutation testing metrics are insufficient: The study highlights the need for commit-aware test metrics to accurately assess the effectiveness of testing evolving systems.

Key Results

  • Approximately 30% of all mutants are commit-relevant on average.
  • 81% of commit-relevant mutants are located outside the developers' committed changes.
  • Selecting subsuming commit-relevant mutants can reduce the number of mutants to be considered by up to 79% and 93% compared to commit-relevant mutants and all mutants, respectively.
  • Commit-aware mutation testing can reduce test execution cost by up to 16 times compared to analyzing all mutants.
  • Random mutant selection is up to 1.6 times less effective than selecting commit-relevant mutants.

Limitations and Future Work

The authors acknowledge several limitations:

  • External Validity: The findings are based on a specific set of Java projects and tools (Pitest, EvoSuite). Generalizability to other languages, projects, or mutation tools might vary. They encourage replication of their study.
  • Internal Validity: Potential issues with the implementation of their tools and analysis are acknowledged. They mitigated this by manual testing and repeating experiments.
  • Construct Validity: Their approach provides an approximation of commit-relevant mutants due to the finite set of test cases and mutants. The potential for equivalent mutants (mutants that behave identically to the original code) is also a concern, though they employed standard methods to mitigate this.
  • Granularity of Assertion Checks: Their assertion checks are coarse-grained (parameter level). More fine-grained checks might reveal more commit-relevant mutants.
  • Efficiency Measure: Efficiency is measured by the number of test executions, assuming similar execution times. This might not perfectly reflect actual execution time differences.

Future work suggested includes:

  • Developing automated methods (statistical, machine learning, program analysis) for identifying and selecting commit-relevant mutants.
  • Investigating new test metrics tailored for commit-aware mutation testing.
  • Exploring the impact of assertion granularity on commit-aware mutation testing.
  • Developing techniques that consider program dependencies to focus mutant injection.

Summary updated

BibTeX
@article{ojdanic2021mutation,
  author = {Milos Ojdanic and Ezekiel Soremekun and Renzo Degiovanni and Mike Papadakis and Yves Le Traon},
  title = {{Mutation Testing in Evolving Systems: Studying the relevance of mutants to code evolution}},
  journal = {ACM Trans. Softw. Eng. Methodol.},
  year = {2021},
  doi = {10.1145/3530786},
}
Figure