arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2602.08146cs.SE
收藏

测试与突变:对抗性LLM代理用于鲁棒性单元测试生成

Test vs Mutant: Adversarial LLM Agents for Robust Unit Test Generation

Shanghai Jiao Tong University(上海交通大学)

Pengyu Chang, Yixiong Fang, Silin Chen, Yuling Shi, Beijun Shen, Xiaodong Gu

AI总结:

AdverTest通过对抗性代理提升单元测试生成的鲁棒性,提高故障检测率和覆盖率

摘要:

软件测试是软件开发生命周期中的关键但资源密集的阶段。多年来,各种自动化工具已被开发出来帮助此过程。基于搜索的方法通常能实现高覆盖率,但生成的测试可读性较低,而基于大型语言模型(LLM)的方法生成的测试更具人类可读性,但往往在覆盖率和可编译性上表现较差。尽管大多数研究努力集中在提高测试覆盖率和可读性上,但很少有人关注增强错误检测的鲁棒性,特别是在暴露边缘情况和易受攻击的执行路径方面。为了解决这一差距,我们提出了AdverTest,一种新的对抗性框架,用于LLM驱动的测试用例生成。AdverTest由两个相互作用的代理组成:测试用例生成代理(T)和突变生成代理(M)。这些代理进行对抗性循环,其中M持续生成新的突变“黑客”T当前测试套件的盲点,而T则逐步完善其测试用例以“杀死”M生成的具有挑战性的突变。这种交互循环由覆盖率和突变得分引导,使系统能够共同进化,朝着高测试覆盖率和错误检测能力发展。在Defects4J数据集上的实验结果表明,我们的方法在现有LLM方法上提高了8.56%的故障检测率,并在EvoSuite上提高了63.30%,同时提高了行和分支覆盖率。

英文摘要:

Software testing is a critical, yet resource-intensive phase of the software development lifecycle. Over the years, various automated tools have been developed to aid in this process. Search-based approaches typically achieve high coverage but produce tests with low readability, whereas large language model (LLM)-based methods generate more human-readable tests but often suffer from low coverage and compilability. While the majority of research efforts have focused on improving test coverage and readability, little attention has been paid to enhancing the robustness of bug detection, particularly in exposing corner cases and vulnerable execution paths. To address this gap, we propose AdverTest, a novel adversarial framework for LLM-powered test case generation. AdverTest comprises two interacting agents: a test case generation agent (T) and a mutant generation agent (M). These agents engage in an adversarial loop, where M persistently creates new mutants "hacking" the blind spots of T's current test suite, while T iteratively refines its test cases to "kill" the challenging mutants produced by M. This interaction loop is guided by both coverage and mutation scores, enabling the system to co-evolve toward both high test coverage and bug detection capability. Experimental results in the Defects4J dataset show that our approach improves fault detection rates by 8.56% over the best existing LLM-based methods and by 63.30% over EvoSuite, while also improving line and branch coverage.

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

↑