NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Syntactic Vs. Semantic similarity of Artificial and Real Faults in Mutation Testing Studies

Milos Ojdanic, Aayush Garg, Ahmed Khanfir, Renzo Degiovanni, Mike Papadakis, Yves Le TraonarXiv 2021

Abstract

Fault seeding is typically used in controlled studies to evaluate and compare test techniques. Central to these techniques lies the hypothesis that artificially seeded faults involve some form of realistic properties and thus provide realistic experimental results. In an attempt to strengthen realism, a recent line of research uses advanced machine learning techniques, such as deep learning and Natural Language Processing (NLP), to seed faults that look like (syntactically) real ones, implying that fault realism is related to syntactic similarity. This raises the question of whether seeding syntactically similar faults indeed results in semantically similar faults and more generally whether syntactically dissimilar faults are far away (semantically) from the real ones. We answer this question by employing 4 fault-seeding techniques (PiTest, IBIR, DeepMutation, and CodeBERT) and demonstrate that syntactic similarity does not reflect semantic similarity. We also show that 60%, 47%, 43%, and 7% of the real faults of Defects4J V2 are semantically resembled by CodeBERT, PiTest, IBIR, and DeepMutation faults, respectively. We find that CodeBERT and PiTest have similar fault detection capabilities that subsume IBIR and DeepMutation, and that IBIR is the most cost-effective technique.

Introduction

In software testing, mutation testing serves as a critical benchmark for evaluating test suite effectiveness by intentionally introducing artificial bugs, or "mutants." The utility of this approach hinges on the assumption that these artificial faults behave similarly to real-world errors. Recently, a trend has emerged toward using Machine Learning (ML) and Natural Language Processing (NLP) to create mutants that "mimic" the syntactic structure of real faults found in version control histories. This shift is predicated on the belief that syntactic similarity (how code looks) is a proxy for semantic similarity (how code behaves). This study challenges this assumption, investigating whether "looking real" actually translates to "being real" in a functional sense.

Methodology

We compared four distinct fault-seeding techniques:

  1. PiTest: The industry standard, employing simple syntactic transformations at the bytecode level.
  2. IBIR: A tool utilizing manually crafted "inverted fix-patterns" based on real bug fixes.
  3. DeepMutation: A deep learning framework that uses Neural Machine Translation to generate buggy code from healthy code.
  4. CodeBERT: A novel approach using pre-trained code embeddings to replace tokens based on implicit programming norms.

To evaluate these tools, we used the Defects4J v2.0.0 benchmark, analyzing 509 real-world faults and generating over 1.3 million mutants. Realism was measured using two primary metrics: BLEU scores for syntactic similarity and the Ochiai coefficient for semantic similarity (measuring the overlap in failed test cases between mutants and real faults).

Results and Analysis

The Disconnect Between Syntax and Semantics

A core finding of this research is the lack of correlation between a mutant's appearance and its behavior. As illustrated in the scatter plots below, there is almost zero correlation between BLEU scores and Ochiai coefficients. Mutants that are nearly identical to real faults syntactically often fail to replicate their semantic behavior, while simple, syntactically distant mutants can often mirror complex real-world faults through the "coupling effect."

Correlation between syntactic similarity (BLEU) and semantic resemblance (OCHIAI) for different techniques.

Comparative Performance of Seeding Techniques

When evaluating semantic resemblance, CodeBERT proved most effective, resembling 60.42% of real faults, followed by PiTest (46.85%) and IBIR (43.01%). DeepMutation trailed significantly at 6.9%. While IBIR is highly cost-effective for generating a small number of very realistic-looking bugs, it lacks the thoroughness of PiTest and CodeBERT. Notably, PiTest and CodeBERT mutants were found to subsume the majority of ground covered by the other tools.

Distribution of semantic resemblance (OCHIAI) scores across the four evaluated techniques.

Conclusion

Our results demonstrate that syntactic mimicry does not guarantee semantic realism. While AI-driven approaches like CodeBERT show significant promise by leveraging code context, traditional simple mutation operators remain highly effective. Future advancements in mutation testing should focus on understanding code semantics and context rather than merely replicating syntactic patterns. For practitioners, the takeaway is clear: focus on the behavior of faults, not just their surface-level appearance.

Summary updated

BibTeX
@misc{ojdanic2021syntactic,
  author = {Milos Ojdanic and Aayush Garg and Ahmed Khanfir and Renzo Degiovanni and Mike Papadakis and Yves Le Traon},
  title = {{Syntactic Vs. Semantic similarity of Artificial and Real Faults in Mutation Testing Studies}},
  year = {2021},
  eprint = {2112.14508},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2112.14508},
}
Figure