自动化测试生成已有大量研究工作,但多数研究关注为完整软件单元(如类)生成测试,并依赖代码覆盖率等指标进行评估。相比之下,现代软件开发主要通过拉取请求(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.
An Empirical Study on the Potential of LLMs in Automated Software Refactoring
Beijing Institute of Technology(北京理工大学);Peking University(北京大学);University of Cincinnati(辛辛那提大学);National Innovation Institute of Defense Technology(国防科技大学创新研究院)
A System for Automated Unit Test Generation Using Large Language Models and Assessment of Generated Test Suites
Polytechnic University of Bari \& Wideverse Bari, Italy;Polytechnic University of Bari Bari, Italy;Independent Researcher;University of Bari Bari, Italy
SPARC: Scenario Planning and Reasoning for Automated C Unit Test Generation
Bangladesh University of Engineering and Technology(孟加拉工程科技大学);National Taiwan University(台湾国立大学);University of Illinois at Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校)
Testing Storage-System Correctness: Challenges, Fuzzing Limitations, and AI-Augmented Opportunities
Institute of Computing Technology, Chinese Academy of Sciences (ICT, CAS)(中国科学院计算技术研究所);University of Chinese Academy of Sciences(中国科学院大学);Zhongguancun Laboratory(中关村实验室)