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

PR感知的自动化单元测试生成:挑战与机遇

PR-Aware Automated Unit Test Generation: Challenges and Opportunities

Bilkent University(比尔肯特大学);Purdue University(普渡大学)

Vahid Haratian, Atakan Akar, Berk Çakar, Eray Tüzün

AI总结:

本研究评估了EvoSuite和GPT-4o在拉取请求(PR)级别生成测试用例的能力,发现两者均难以有效生成捕获变更的测试,但EvoSuite优于GPT-4o,并指出智能体代码生成方法具有潜力。

摘要:

自动化测试生成已有大量研究工作,但多数研究关注为完整软件单元(如类)生成测试,并依赖代码覆盖率等指标进行评估。相比之下,现代软件开发主要通过拉取请求(PR)中引入的小型、针对性变更来演进。然而,专门为这些PR生成测试的关键任务被忽视,且现有最先进工具在此任务上的性能尚不明确。本研究评估了两种不同的PR感知测试生成方法:EvoSuite(领先的基于搜索的工具)和GPT-4o(广泛使用的大语言模型之一)。为衡量它们验证PR特定变更的有效性,我们评估其生成失败到通过(F2P)测试用例的能力,即测试在变更前代码上失败,在变更后代码上通过。评估显示,EvoSuite优于GPT-4o,在显著更高比例的PR中至少生成一个F2P测试(36% vs. 13%)。GPT-4o的性能受到高编译错误率(63%)的严重阻碍,而EvoSuite生成的测试中仅有2%无法运行。尽管EvoSuite相对成功,但我们的发现表明,这两种工具在此任务上基本无效,因为它们未能为大多数PR(64%)生成任何有意义的捕获变更的测试。虽然两个生成器在我们的评估中均未能实现高F2P比率,且EvoSuite优于GPT-4o,但我们认为智能体代码生成方法在此任务上具有显著潜力。最终,我们的工作突显了工具方面的关键缺口,并呼吁开发针对现代软件开发增量性质的高性能测试生成器。

英文摘要:

Automated test generation has a substantial body of work, yet most studies focus on generating tests for complete software units, such as classes, and rely on metrics such as code coverage for assessment. In contrast, modern software development primarily evolves through small, targeted changes introduced in pull requests (PRs). Despite this, the crucial task of generating tests specifically for these PRs has been overlooked, and the performance of state-of-the-art tools for this purpose remains unknown. This study evaluates two distinct approaches for PR-aware test generation: EvoSuite, a leading search-based tool, and GPT-4o, one of the widely used large language models (LLMs). To measure their effectiveness at validating PR-specific changes, we assess their ability to generate fail-to-pass (F2P) test cases, meaning tests that fail on the code before the change and pass on the code after the change. Our evaluation shows that EvoSuite outperformed GPT-4o, producing at least one F2P test for a significantly higher percentage of PRs (36 percent vs. 13 percent). The performance of GPT-4o was significantly hampered by a high rate of compilation errors (63 percent), whereas only 2 percent of EvoSuite's generated tests failed to run. Despite EvoSuite's relative success, our findings indicate that both tools are largely ineffective for this task, as they failed to generate any meaningful change-capturing tests for the large majority of the PRs (64 percent). Although both generators could not achieve a high F2P ratio in our evaluation, and EvoSuite outperformed GPT-4o, we believe that agentic code generation methods may have significant potential for this task. Ultimately, our work highlights a critical gap in tooling and calls for the development of high-performance test generators tailored to the incremental nature of modern software development.

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

↑