FailMapper: Automated Generation of Unit Tests Guided by Failure Scenarios
Ruiqi Dong, Zehang Deng, Xiaogang Zhu, Xiaoning Du, Huai Liu, Shaohua Wang, Sheng Wen, Yang Xiang
Abstract
The automation of unit test generation has become a critical task for improving the overall efficiency of software development and testing. Many existing techniques attempt to generate a sufficient number of test cases to achieve high code coverage. However, it has been shown that a high coverage does not necessarily guarantee effective bug discovery. A potential enhancement is to guide the unit test generation based on bug properties. However, this solution is challenged by the large number and diversity of bug types, making it difficult to comprehensively summarize bug properties.We observe that failures, presented as the results of bugs, manifest in a limited number of scenarios. Therefore, instead of bug properties, in this paper, we propose an innovative framework, named FailMapper, which uses failure scenarios to guide the generation of unit tests. We summarize nine failure scenarios and design the corresponding failure-triggering test strategies. This significantly improves the efficacy of generating test cases towards triggering bugs. To systematically explore possible failure scenarios, FailMapper employs the Monte Carlo Tree Search algorithm to search for the faults that may lead to a failure. Experiments demonstrate that, on 50 known bugs in the Defects4J benchmark, FailMapper can detect many more bugs than five typical unit testing approaches, including EvoSuite, Randoop, CoverUp, HITS, and SymPrompt (40 versus at most 12, out of all 50 bugs). Meanwhile, FailMapper detects 12 out of 20 bugs in the GitBug-Java and Bears-benchmark datasets. We reveal 36 potential issues from 2 Apache projects, and 14 of them have been confirmed as bugs, further demonstrating FailMapper’s effectiveness. The experimental results show that our new framework can significantly enhance the overall efficacy of unit testing.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Your agent calls
Lunesearch_papers
Free to start. No credit card required.
Terminal
Install the CLIlune papers get 7cc872ed-1a13-4a1d-9d01-35fe7cf789d8Related papers
- Effective Unit Test Generation for Java Null Pointer ExceptionsMyungho Lee, Jiseong Bak, Seokhyeon Moon, Yoonchan Jhi et al.ASE 2024 · 1 citation
- Large Language Models are Few-shot Testers: Exploring LLM-based General Bug ReproductionSungmin Kang, Juyeon Yoon, Shin YooICSE 2023 · 163 citations
- Test vs Mutant: Adversarial LLM Agents for Robust Unit Test GenerationPengyu Chang, Yixiong Fang, Silin Chen, Yuling Shi et al.ISSTA 2026
- Automatic Unit Test Generation for Machine Learning Libraries: How Far Are We?Song Wang, Nishtha Shrestha, Abarna Kucheri Subburaman, Junjie Wang et al.ICSE 2021 · 36 citations
- Defect Prediction Guided Search-Based Software TestingAnjana Perera, Aldeida Aleti, Marcel Böhme, Burak TurhanASE 2020 · 16 citations
