Beyond Rule-Based Mutation Testing: Test-Aware Mutant Generation Using Large Language Models
cs.SE, cs.AI
Submitted: 2026-09-24
Updated: 2026-09-24
Comments: 20 pages, 7 figures. Accepted to ESEM 2026
DOI: 10.4230/LIPIcs.ESEM.2026.49
Code: https://github.com/codingWhale13/test-aware-mutants
License: http://creativecommons.org/licenses/by/4.0/
The gist: Mutation testing evaluates test-suite adequacy by injecting synthetic faults into program code.
Abstract
Mutation testing evaluates test-suite adequacy by injecting synthetic faults into program code. However, traditional rule-based tools often generate large numbers of trivial, redundant, or equivalent mutants that limit their practical use for identifying gaps in a test suite. While recent large language model (LLM)-based approaches generate more realistic faults, most remain test-blind: The model sees only the source code and cannot reason about what existing tests already cover. We propose test-aware mutant generation, in which an LLM receives the problem statement, canonical solution and base tests in a single prompt, and must generate a nontrivial mutant that passes the base unit tests. We evaluate this approach across a set of five LLMs -- Gemini 3.1 Pro, Gemini 3 Flash, GPT 5.1 Codex Mini, GPT 4.1 Mini, Qwen3-32B -- on the HumanEval and MBPP benchmarks. The extended EvalPlus test suites serve as an automated oracle to verify whether surviving mutants represent genuine bugs. Test-aware prompting yields verified fault rates of 87.7% (HumanEval) and 79.1% (MBPP), meaning these mutants pass all base tests but are caught by the oracle. This vastly outperforms the matched test-blind prompting (which yields only 12.2% and 23.0%, respectively) and the traditional rule-based tool mutmut (4.4% and 5.7%). While fault subtlety (the fraction of extended tests a mutant fails) remains comparable across all three methods, test-awareness minimizes the computational cost per verified fault, compared to test-blind prompting. Exposing an LLM to existing unit tests shifts mutant generation from untargeted bug injection toward effective discovery of weaknesses in an existing test suite. Our work establishes a concrete foundation for future research to scale test-aware mutant generation to production-level environments.
Sources
- Program Synthesis with Large Language Models
- Test vs Mutant: Adversarial LLM Agents for Robust Unit Test Generation
- Evaluating Large Language Models Trained on Code
- SWE-Lego: Pushing the Limits of Supervised Fine-tuning for Software Issue Resolving
- CodeTaste: Can LLMs Generate Human-Level Code Refactorings?
- Vibe Code Bench: Evaluating AI Models on End-to-End Web Application Development
Related papers
- Falsification-Based Verification of LLM-Generated Optimization Models: Sound Test Batteries and Their Detection Limits
- GitSkills: A Dataset of Agent Skills on GitHub
- SABER: Benchmarking Operational Safety of LLM Coding Agents in Stateful Project Workspaces
- PackMonitor: Enabling Zero Package Hallucinations Through Decoding-Time Monitoring
- IntentCoding: Amplifying User Intent in Code Generation
- Incentives and Outcomes in Bug Bounties