paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Unit Test Update through LLM-Driven Context Collection and Error-Type-Aware Refinement

通过 LLM 驱动的上下文收集与错误类型感知精化实现单元测试更新
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 3/10 · 论文属于LLM辅助的单元测试更新与修复,虽与PL+ML交叉相关,但不涉及用户核心关注的静态分析、形式化验证、Agentic程序分析、浮点或贝叶斯程序分析。其LLM用法偏向测试维护工程,而非用LLM改进静态分析或分析LLM程序。引用 1 inbox
Yuanhe Zhang, Zhiquan Yang, Shengyi Pan, Zhongxin Liu
crossref: 2026-09-12

AI 速览

一句话:提出基于 LLM 的 TestUpdater,在代码变更时自动修复并增强单元测试,并构建了 Updates4J 基准。

单元测试对软件质量至关重要,但人工维护效率低且易遗漏。现有自动化测试维护方法主要修复破损测试,忽略了增强既有测试以验证新功能的场景;同时其依赖规则化的上下文收集且缺乏验证机制,难以应对复杂代码变更,生成用例正确率低。本文提出 TestUpdater,一种基于大语言模型(LLM)的即时测试更新方法:它先模拟开发者的推理过程,用 LLM 分析代码变更并识别相关上下文,再抽取与过滤,从而灵活获得准确充分的上下文;随后通过精心设计的提示逐步处理各类代码变更与新引入依赖,同时支持破损测试修复与测试增强;最后模拟调试过程,引入错误类型感知的迭代精化机制,执行更新后的测试并修复失败。为评估测试增强场景,作者构建了包含 7 个项目、195 个真实样本的 Updates4J 基准。实验表明,TestUpdater 编译通过率达 94.4%、测试通过率 86.7%,分别比最先进的 Synter 高出 15.9% 和 20.0%,分支覆盖率与行覆盖率也分别高出 12.9% 和 15.2%。

问题
现有自动化测试维护方法只关注修复破损测试,无法增强测试以验证新功能;且依赖规则化上下文收集、缺乏验证机制,难以处理复杂代码变更,导致更新后的测试正确率低。
方法
提出 TestUpdater:利用 LLM 模拟开发者推理,分析代码变更并识别、抽取和过滤相关上下文;通过精心设计的提示逐步处理各类代码变更与新依赖;并引入错误类型感知的迭代精化机制执行测试、修复失败。
评估
构建了包含 7 个项目、195 个真实样本、支持基于执行评估的 Updates4J 基准,并与最先进方法 Synter 对比编译通过率、测试通过率及分支/行覆盖率。
原文摘要(Abstract)

Unit testing is critical for ensuring software quality and software system stability. The current practice of manually maintaining unit tests suffers from low efficiency and the risk of delayed or overlooked fixes. Therefore, an automated approach is required to instantly update unit tests, with the capability to both repair and enhance unit tests. However, existing automated test maintenance methods primarily focus on repairing broken tests, neglecting the scenario of enhancing existing tests to verify new functionality. Meanwhile, due to their reliance on rule-based context collection and the lack of verification mechanisms, existing approaches struggle to handle complex code changes and often produce test cases with low correctness.To address these challenges, we propose TestUpdater, a novel Large Language Model (LLM) based approach that enables automated just-in-time test updates in response to production code changes. By emulating the reasoning process of developers, TestUpdater first leverages the LLM to analyze code changes and identify relevant context, which it then extracts and filters. This LLM-driven context collector can flexibly gather accurate and sufficient context, enabling better handling of complex code changes. Then, through carefully designed prompts, TestUpdater guides the LLM step by step to handle various types of code changes and introduce new dependencies, enabling both the repair of broken tests and the enhancement of tests. Finally, emulating the debugging process, we introduce an error-type-aware iterative refinement mechanism that executes the LLM-updated tests and repairs failures, which significantly improves the overall correctness of test updates.Since existing test repair datasets lack scenarios of test enhancement, we further construct a new benchmark, Updates4J, with 195 real-world samples from 7 projects, enabling execution-based evaluation of test updates. Experimental results show that TestUpdater achieves a compilation pass rate of 94.4% and a test pass rate of 86.7%, outperforming the state-of-the-art method Synter by 15.9% and 20.0%, respectively. Furthermore, TestUpdater exhibits 12.9% higher branch coverage and 15.2% greater line coverage than Synter.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9443,
  title = {Unit Test Update through LLM-Driven Context Collection and Error-Type-Aware Refinement},
  author = {Yuanhe Zhang and Zhiquan Yang and Shengyi Pan and Zhongxin Liu},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00206}
}