一句话:结合轻量程序分析与 LLM,通过后向切片、相似测试用例和执行内联标注生成回归测试,缓解覆盖率停滞。
针对基于大语言模型的回归测试生成中因缺乏对程序执行的推理而出现的覆盖率停滞(coverage plateau)问题,本文提出 TestWeaver。该方法将轻量级程序分析融入 LLM 的输入构造:(1) 用目标行的后向切片替代完整程序上下文,减少幻觉并提升聚焦度;(2) 识别与目标行路径具有控制流相似性的邻近测试用例,在有限上下文窗口内提供执行相关的上下文;(3) 沿执行路径以注释形式内联标注变量状态,增强模型对执行的推理。通过这些有针对性的上下文化输入,TestWeaver 改善了覆盖率引导的测试生成并抑制冗余探索。实证结果表明,与当前最优方法相比,TestWeaver 加快了代码覆盖率的增长,并生成更有效的测试用例。
While recent advances in large language models (LLMs) have shown promise in automating test generation for regression testing, they often suffer from limited reasoning about program execution, resulting in stagnated coverage growth—a phenomenon known as the coverage plateau. This paper presents TestWeaver, a novel LLM-based approach that integrates lightweight program analysis to create a focused execution context that assists LLMs in better test generation. TestWeaver strategically chooses the following components to overcome LLMs’ limited reasoning on complex execution: (1) it reduces hallucinations and improves focus by supplying the LLM with the backward slice from the target line instead of a full program context; (2) it identifies and incorporates close test cases—those that share control-flow similarities with the path to the target line—to provide focused execution context within the LLM’s context window; and (3) it enhances LLM’s reasoning with execution in-line annotations that encode variable states as comments along the executed path. By equipping LLMs with these targeted and contextualized inputs, it improves coverage-guided test generation and mitigates redundant explorations. Empirical results show that TestWeaver accelerates code coverage growth and generates more effective test cases than the state-of-the-art approaches.
@inproceedings{abs-2508-01255,
title = {TestWeaver: Execution-aware, Feedback-driven Regression Testing Generation with Large Language Models},
author = {Cuong Chi Le and Cuong Duc Van and Tung Duy Vu and Minh Vu Thai Pham and Nhat Hoang Phan and Huy Phan and Tien N. Nguyen},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3744916.3787805}
}