arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.18316cs.SE
收藏

YATE:测试修复在基于 LLM 的单元测试生成中的作用

YATE: The Role of Test Repair in LLM-Based Unit Test Generation

Michael Konstantinou, Renzo Degiovanni, Jie M. Zhang, Mark Harman, Mike Papadakis

AI总结:

针对 LLM 生成单元测试常含语法或语义错误的问题,本文提出 YATE,结合静态分析与重新提示修复错误测试,并在 6 个项目上验证其以相当调用成本显著提升覆盖率和变异杀死率。

摘要:

自动化测试生成的最新进展利用语言模型来生成单元测试。尽管有效,但语言模型往往会生成许多在语法和语义上都不正确的测试。虽然这些不正确的测试可以被轻易检测并丢弃,但它们构成了一个“错失的机会”——如果被修复,它们通常很有价值,因为它们直接增加测试价值(实际上针对待测试的底层程序逻辑),并间接形成用于生成额外测试的良好种子。为此,我们提出一种简单技术,通过结合基于规则的静态分析和重新提示来修复其中一些不正确的测试。我们在 6 个开源项目集合上评估了这个名为 YATE 的简单方法,结果表明,与普通的基于 LLM 的方法相比,它能够有效生成测试,平均多覆盖 32.06% 的代码行,并多杀死 21.77% 的变异体。我们还将 YATE 与其他四种基于 LLM 的方法(即 HITS、SYMPROMPT、TESTSPARK 和 COVERUP)进行比较,结果表明它生成的测试覆盖显著更多的代码。在成本(对 LLM 的调用次数)相当的情况下,YATE 的行覆盖率高出 22%,分支覆盖率高出 20%,并多杀死 20% 的变异体。

英文摘要:

Recent advances in automated test generation utilises language models to produce unit tests. While effective, language models tend to generate many incorrect tests with respect to both syntax and semantics. Although such incorrect tests can be easily detected and discarded, they constitute a "missed opportunity" -- if fixed, they are often valuable as they directly add testing value (they effectively target the underlying program logic to be tested) and indirectly form good seeds for generating additional tests. To this end, we propose a simple technique for repairing some of these incorrect tests through a combination of rule-based static analysis and re-prompting. We evaluate this simple approach, named YATE, on a set of 6 open-source projects and show that it can effectively produce tests that cover on average 32.06% more lines and kill 21.77% more mutants than a plain LLM-based method. We also compare YATE with four other LLM-based methods, namely HITS, SYMPROMPT, TESTSPARK and COVERUP and show that it produces tests that cover substantially more code. YATE achieves 22% higher line coverage, 20% higher branch coverage and kill 20% more mutants at a comparable cost (number of calls to LLMs).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑