TestForge:反馈驱动的智能体测试套件生成
TestForge: Feedback-Driven, Agentic Test Suite Generation
AI总结:
本文提出反馈驱动的智能体框架 TestForge,通过执行与覆盖率反馈迭代改进零样本生成的单元测试,在 TestGenEval 上以低成本取得更高覆盖率、变异分数和可读性。
摘要:
自动化测试生成在减轻手动创建测试的负担方面具有巨大前景。然而,现有的基于搜索的技术会牺牲测试可读性,而基于 LLM 的方法在实践中成本高得令人望而却步。我们提出 TestForge,这是一个智能体单元测试框架,旨在以高性价比为真实世界代码生成高质量测试套件。我们的关键洞见是将基于 LLM 的测试生成重新构建为一个迭代过程。因此,TestForge 首先通过零样本提示生成测试,然后基于来自测试执行和覆盖率报告的反馈持续改进这些测试。我们在 TestGenEval 上评估 TestForge,这是一个源自 11 个大规模开源代码仓库的真实世界单元测试生成基准;我们表明,TestForge 平均达到 84.3% 的 pass@1 率、44.4% 的行覆盖率和 33.8% 的变异分数,优于此前的经典方法以及单轮基于 LLM 的基线。与最先进的基于搜索的技术相比,TestForge 生成更自然、更易理解的测试,并且相比基于 LLM 的技术提供显著的成本节约(每个文件 0.63 美元)。最后,我们发布了一个与 OpenHands 平台集成的 TestGenEval 版本,OpenHands 是一个流行的开源框架,具有多样化的软件工程智能体和智能体基准,可供未来扩展和开发。
英文摘要:
Automated test generation holds great promise for alleviating the burdens of manual test creation. However, existing search-based techniques compromise on test readability, while LLM-based approaches are prohibitively expensive in practice. We present TestForge, an agentic unit testing framework designed to cost-effectively generate high-quality test suites for real-world code. Our key insight is to reframe LLM-based test generation as an iterative process. TestForge thus begins with tests generated via zero-shot prompting, and then continuously refines those tests based on feedback from test executions and coverage reports. We evaluate TestForge on TestGenEval, a real world unit test generation benchmark sourced from 11 large scale open source repositories; we show that TestForge achieves a pass@1 rate of 84.3%, 44.4% line coverage and 33.8% mutation score on average, outperforming prior classical approaches and a one-iteration LLM-based baseline. TestForge produces more natural and understandable tests compared to state-of-the-art search-based techniques, and offers substantial cost savings over LLM-based techniques (at $0.63 per file). Finally, we release a version of TestGenEval integrated with the OpenHands platform, a popular open-source framework featuring a diverse set of software engineering agents and agentic benchmarks, for future extension and development.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。