一句话:提出 ChaCo,用 LLM 针对 PR 中未覆盖行增强回归测试,并友好集成到现有测试套件。
PR 中修改代码常留下“最后一英里”回归测试缺口,现有测试生成器多优化整体覆盖率而非 PR 未覆盖行。ChaCo 是基于 LLM 的测试增强方法:针对具体 PR 应用后的未覆盖行生成测试,提取相关测试函数、fixture 和数据生成器提供上下文,并匹配现有风格集成且生成审查摘要。在 SciPy、Qiskit、Pandas 的 145 个 PR 上,30% 实现完整补丁覆盖,成本 0.11 美元/PR;人工评价中测试值得加入 4.53、集成良好 4.20、与 PR 相关 4.70(均满分 5)。消融显示测试上下文可带来 2 倍覆盖;提交 12 个测试,8 个已合并,并发现并修复两个未知缺陷。
Software is in constant evolution, with developers frequently submitting pull requests (PRs) to introduce new features or fix bugs. Testing newly added or modified code in PRs is critical to maintaining software quality. Yet, even in projects with extensive test suites, some of the code modified in PRs may remain untested, leaving a “last-mile” regression test gap. Existing automated test generators mostly focus on improving overall code coverage, but do not specifically target the uncovered lines in PRs. This paper presents Change And Cover (ChaCo), a novel, LLM-based test augmentation technique that specifically addresses the last-mile regression test gap in PRs. Our approach is enabled by three key contributions: (i) Instead of focusing on overall code coverage, ChaCo considers a specific PR and the lines left uncovered after applying the PR, offering developers augmented tests for code just when it is on the developers’ mind. (ii) We identify providing suitable test context as a crucial challenge for an LLM to generate useful tests, and present two techniques to extract relevant test content, such as existing test functions, fixtures, and data generators. (iii) To make augmented tests acceptable for developers, ChaCo carefully integrates them into the existing test suite, e.g., by matching the test’s structure and style with the existing tests, and generates a summary of the test addition for developer review. We evaluate ChaCo on 145 PRs from three popular, complex, and well-tested open-source projects—SciPy, Qiskit, and Pandas. The approach successfully helps 30% of PRs achieve full patch coverage, at the affordable cost of $0.11 per PR, demonstrating its effectiveness and feasibility. A qualitative assessment of the generated tests shows that human reviewers find the tests to be worth adding (4.53/5.0), well integrated (4.20/5.0), and relevant to the PR (4.70/5.0). Ablation studies show test context is crucial for context-aware test generation, leading to 2 × coverage. In a contribution study, we submitted 12 tests to these projects, of which 8 have already been merged, and two previously unknown bugs were discovered and fixed. We envision our approach to be integrated into CI workflows, automating the last mile of regression test augmentation.
@inproceedings{abs-2601-10942,
title = {Change And Cover: Last-Mile, Pull Request-Based Regression Test Augmentation},
author = {Zitong Zhou and Matteo Paltenghi and Miryung Kim and Michael Pradel},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3744916.3787768}
}