Unit tests play a vital role in uncovering potential faults in software. While tools like EvoSuite focus on maximizing code coverage, recent advances in large language models (LLMs) have shifted attention toward LLM-based test generation. However, code coverage metrics -- such as line and branch coverage -- remain overly emphasized in reported research, despite being weak indicators of a test suite's fault-detection capability. In contrast, mutation score offers a more reliable and stringent measure, as demonstrated in our findings where some test suites achieve 100% coverage but only 4% mutation score. Although a few studies consider mutation score, the effectiveness of LLMs in killing mutants remains underexplored. In this paper, we propose MUTGEN, a mutation-guided, LLM-based test generation approach that incorporates mutation feedback directly into the prompt. Evaluated on 204 subjects from two benchmarks, MUTGEN significantly outperforms both EvoSuite and vanilla prompt-based strategies in terms of mutation score. Furthermore, MUTGEN introduces an iterative generation mechanism that pushes the limits of LLMs in killing additional mutants. Our study also provide insights into the limitations of LLM-based generation, analyzing the reasons for live and uncovered mutants, and the impact of different mutation operators on generation effectiveness.


翻译:单元测试在揭示软件潜在缺陷方面发挥着至关重要的作用。尽管EvoSuite等工具侧重于最大化代码覆盖率,但大型语言模型(LLMs)的最新进展已将研究焦点转向基于LLM的测试生成。然而,在已报道的研究中,代码覆盖率指标——如行覆盖率和分支覆盖率——仍然被过度强调,尽管它们对测试套件缺陷检测能力的指示作用较弱。相比之下,变异分数提供了更可靠且更严格的度量标准,我们的研究结果也证明了这一点:某些测试套件实现了100%的覆盖率,但变异分数仅为4%。尽管少数研究考虑了变异分数,但LLM在杀死变异体方面的有效性仍未得到充分探索。本文提出MUTGEN,一种基于LLM的变异导向测试生成方法,该方法将变异反馈直接整合到提示中。在两个基准测试的204个实验对象上进行的评估表明,MUTGEN在变异分数方面显著优于EvoSuite和基于原始提示的策略。此外,MUTGEN引入了迭代生成机制,突破了LLM在杀死额外变异体方面的能力极限。我们的研究还深入探讨了基于LLM的生成方法的局限性,分析了存活和未覆盖变异体的原因,以及不同变异算子对生成效果的影响。

0
下载
关闭预览

相关内容

专知会员服务
30+阅读 · 2020年9月18日
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员