paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Test Intention Guided LLM-Based Unit Test Generation

测试意图引导的基于大语言模型的单元测试生成
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 3/10 · 该论文聚焦于用 LLM 生成单元测试(含 mock 能力与覆盖率提升),属于 LLM 辅助软件测试方向,与用户关注的“LLM/Agent 改进静态分析或形式化验证”并非同一问题;虽然涉及 LLM 与程序语言的交叉且有工业落地验证,但缺少静态分析、浮点分析或贝叶斯程序分析等核心要素。引用 15 inbox
Zifan Nan, Zhaoqiang Guo, Kui Liu, Xin Xia
crossref: 2026-09-12

AI 速览

一句话:提出 IntUT,用显式测试意图引导 LLM 生成高覆盖且具备 mock 能力的单元测试。

现有基于大语言模型(LLM)直接生成单元测试的方法往往覆盖率低、mock 能力不足,难以在实际开发中落地。本文提出 IntUT,通过显式的测试意图(如测试输入、mock 行为与预期结果)来有效引导 LLM,使其生成高质量测试用例。作者在三个工业 Java 项目及 live study 上进行了评估,结果表明以测试意图提示 LLM 能显著提升测试质量:分支覆盖率提升 94%,行覆盖率提升 49%。最后,作者收集了开发者使用 IntUT 为三个新 Java 项目生成测试用例的反馈,行覆盖率超过 80%,编写单元测试的效率提升 30% 以上。

问题
现有 LLM 直接生成单元测试的方法覆盖率低且 mock 能力不足,生成的测试在实际项目中往往不实用。
方法
提出 IntUT,利用显式测试意图(测试输入、mock 行为、预期结果)作为提示来引导 LLM 生成高质量单元测试用例。
评估
在三个工业 Java 项目和 live study 上评估,分支覆盖率提升 94%、行覆盖率提升 49%;开发者在新 Java 项目中使用 IntUT 达到超 80% 行覆盖率,编写效率提升 30% 以上。
原文摘要(Abstract)

The emergence of Large Language Models (LLMs) has accelerated the progress of intelligent software engineering technologies, which brings promising possibilities for unit test generation. However, existing approaches for unit tests directly generated from Large Language Models (LLMs) often prove impractical due to their low coverage and insufficient mocking capabilities. This paper proposes IntUT, a novel approach that utilizes explicit test intentions (e.g., test inputs, mock behaviors, and expected results) to effectively guide the LLM to generate high-quality test cases. Our experimental results on three industry Java projects and live study demonstrate that prompting LLM with test intention can generate high-quality test cases for developers. Specifically, it achieves the improvements on branch coverage by 94 % and line coverage by 49 %. Finally, we obtain developers' feedback on using IntUT to generate cases for three new Java projects, achieving over 80 % line coverage and 30 % efficiency improvement on writing unit test cases.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8800,
  title = {Test Intention Guided LLM-Based Unit Test Generation},
  author = {Zifan Nan and Zhaoqiang Guo and Kui Liu and Xin Xia},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00243}
}