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

通过学习模拟信息改进LLM驱动的测试生成

Improving LLM-Driven Test Generation by Learning from Mocking Information

University of Auckland(奥克兰大学);The Hong Kong University of Science and Technology(香港科技大学);University of Minnesota(明尼苏达大学)

Jamie Lee, Flynn Teh, Hengcheng Zhu, Mengzhen Li, Mattia Fazzini, Valerio Terragni

AI总结:

本文提出MOCKMILL方法,利用开发者编写测试中的模拟信息自动生成测试用例,通过迭代生成与修复过程提升测试覆盖率和有效性。

摘要:

大型语言模型(LLMs)近期在自动化单元测试生成中显示出强大潜力。本文探讨了现有测试套件中开发者定义的测试双(通常称为mocks)是否能用于改进LLM驱动的测试生成。为此,我们提出了MOCKMILL,一种基于LLM的技术和工具,通过自动提取开发者编写测试中的模拟信息生成测试用例。MOCKMILL针对在现有测试中被替换的组件,利用编码的占位符和交互期望指导测试生成,并结合迭代生成与修复过程确保可执行测试。我们在六个Java项目中的10个开源类上使用四个LLM评估了MOCKMILL,并将生成的测试与现有项目测试和基线方法生成的测试进行比较。结果表明,MOCKMILL的测试覆盖了现有测试和基线生成测试所遗漏的代码行并杀死了突变体。总体而言,我们的发现提供了初步证据,表明利用模拟信息是增强LLM驱动测试生成的互补且有效的方法。

英文摘要:

Large Language Models (LLMs) have recently shown strong potential for automated unit test generation. This has motivated us to investigate whether developer-defined test doubles (commonly referred to as mocks) available in existing test suites can be leveraged to improve LLM-driven test generation. To this end, we propose MOCKMILL, an LLM-based technique and tool that generates test cases by exploiting mocking information automatically extracted from developer-written tests. MOCKMILL targets components that are replaced by test doubles in existing tests and uses the encoded stubbings and interaction expectations to guide test generation, combined with an iterative generation-and-repair process to ensure executable tests. We evaluated MOCKMILL on 10 open-source classes from six Java projects using four LLMs, and compared the generated tests with existing project tests and tests produced by baseline approaches. The results show that MOCKMILL's tests cover lines of code and kill mutants that existing tests and baseline-generated tests miss. Overall, our findings provide preliminary evidence that leveraging mocking information is a complementary and effective way to enhance LLM-based test generation.

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

↑