arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2407.00225cs.SE
收藏

大规模、独立和全面的LLM生成测试用例能力研究

Large-scale, Independent and Comprehensive study of the power of LLMs for test case generation

University of Luxembourg(卢森堡大学);Singapore Management University(新加坡管理大学);Aalto University(阿尔托大学);Bilkent University(比尔肯特大学)

Wendkûuni C. Ouédraogo, Kader Kaboré, Yinghua Li, Haoye Tian, Anil Koyuncu, Jacques Klein, David Lo, Tegawendé F. Bissyandé

AI总结:

本研究评估了LLM生成单元测试的可靠性与可维护性,发现基于推理的提示技术提升性能,但幻觉驱动的故障仍需混合方法解决。

摘要:

单元测试对于软件可靠性至关重要,但手动创建测试用例耗费时间且常被忽视。基于搜索的软件测试提高了效率,但生成的测试可读性和可维护性较差,而LLM显示出潜力,但缺乏在基于推理的提示和现实场景中的全面评估。本研究首次对LLM生成的单元测试进行了大规模实证评估,分析了四个模型(GPT-3.5、GPT-4、Mistral 7B和Mixtral 8x7B)在EvoSuite上的表现,针对Defects4J、SF110和CMD共216,300个测试用例。我们评估了五种提示技术,ZSL、FSL、CoT、ToT和GToT,评估了可编译性、幻觉驱动的故障、可读性、覆盖率和测试异味。基于推理的提示,特别是GToT,显著提高了可靠性和可编译性,但幻觉驱动的故障仍然持续存在,编译失败率高达86%。虽然LLM生成的测试通常比SBST输出更可读,但反复出现的问题如Magic Number Tests和Assertion Roulette阻碍了可维护性。这些发现表明,结合LLM生成与自动化验证和基于搜索的优化的混合方法对于生产级结果是必要的。

英文摘要:

Unit testing is essential for software reliability, yet manual test creation is time-consuming and often neglected. Search-based software testing improves efficiency but produces tests with poor readability and maintainability, while LLMs show promise but lack comprehensive evaluation across reasoning-based prompting and real-world scenarios. This study presents the first large-scale empirical evaluation of LLM-generated unit tests at the full class level, analyzing four models (GPT-3.5, GPT-4, Mistral 7B, and Mixtral 8x7B) against EvoSuite across 216,300 test cases targeting Defects4J, SF110, and CMD. We evaluate five prompting techniques, ZSL, FSL, CoT, ToT, and GToT, assessing compilability, hallucination-driven failures, readability, coverage, and test smells. Reasoning-based prompting, particularly GToT, significantly enhances reliability and compilability, yet hallucination-driven failures remain persistent, with compilation failure rates reaching 86%. While LLM-generated tests are generally more readable than SBST outputs, recurring issues such as Magic Number Tests and Assertion Roulette hinder maintainability. These findings suggest that hybrid approaches combining LLM-based generation with automated validation and search-based refinement are necessary for production-ready results.

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

↑