paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Navigating the Labyrinth: Path-Sensitive Unit Test Generation with Large Language Models

穿越迷宫:基于大语言模型的路径敏感单元测试生成
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 4/10 · 该论文属于 LLM 辅助的路径敏感单元测试生成,虽涉及程序分析/代码知识与 LLM 结合,但目标是测试生成而非静态分析、形式化验证或 Agentic 程序分析,也未涉及浮点或贝叶斯程序分析,与研究画像核心方向仅弱相关。引用 1 inbox
Dianshu Liao, Xin Yin, Shidong Pan, Chao Ni, Zhenchang Xing, Xiaoyu Sun
crossref: 2026-09-12

AI 速览

一句话:提出 JUnitGenie 框架,将代码知识与 LLM 语义能力结合,实现路径敏感的高覆盖单元测试生成。

单元测试对软件质量保障至关重要,但编写与维护成本高。已有的自动化测试生成方法(传统启发式方法与近期基于大语言模型的方法)本质上是路径不敏感的:它们依赖固定启发式规则或有限的上下文信息,无法推理深层控制流结构,因而在覆盖深层或复杂执行路径时表现不佳。本文提出路径敏感框架 JUnitGenie,通过将代码知识与大语言模型的语义能力相结合来指导上下文感知的单元测试生成。该框架先从 Java 项目中抽取代码知识,再将其蒸馏为结构化提示,引导模型生成高覆盖率测试。作者在来自十个真实 Java 项目的 2258 个复杂焦点方法上进行了评估,结果显示 JUnitGenie 能生成有效测试,相比启发式与基于 LLM 的基线,分支覆盖率与行覆盖率平均分别提升 29.60% 与 31.00%。此外,生成的测试用例还发现了真实缺陷,并已被开发者确认与修复。

问题
现有单元测试生成方法(启发式或基于 LLM)依赖固定规则与有限上下文,路径不敏感,难以推理深层控制流,导致对深层或复杂执行路径的覆盖率不足。
方法
JUnitGenie 先从 Java 项目抽取代码知识,并将其蒸馏为结构化提示,以引导大语言模型进行上下文感知的路径敏感单元测试生成。
评估
在来自 10 个真实 Java 项目的 2258 个复杂焦点方法上评测,分支与行覆盖率较启发式和 LLM 基线平均提升 29.60% 和 31.00%,并发现被开发者确认修复的真实缺陷。
原文摘要(Abstract)

Unit testing is essential for software quality assurance, yet writing and maintaining tests remains time-consuming and error-prone. To address this challenge, researchers have proposed various techniques for automating unit test generation, including traditional heuristic-based methods and more recent approaches that leverage large language models (LLMs). However, these existing approaches are inherently path-insensitive because they rely on fixed heuristics or limited contextual information and fail to reason about deep control-flow structures. As a result, they often struggle to achieve adequate coverage, particularly for deep or complex execution paths. In this work, we present a path-sensitive framework, JUnitGenie, to fill this gap by combining code knowledge with the semantic capabilities of LLMs in guiding context-aware unit test generation. After extracting code knowledge from Java projects, JUnitGenie distills this knowledge into structured prompts to guide the generation of high-coverage unit tests. We evaluate JUnitGenie on 2,258 complex focal methods from ten real-world Java projects. The results show that JUnitGenie generates valid tests and improves branch and line coverage by 29.60% and 31.00% on average over both heuristic and LLM-based baselines. We further demonstrate that the generated test cases can uncover real-world bugs, which were later confirmed and fixed by developers.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9205,
  title = {Navigating the Labyrinth: Path-Sensitive Unit Test Generation with Large Language Models},
  author = {Dianshu Liao and Xin Yin and Shidong Pan and Chao Ni and Zhenchang Xing and Xiaoyu Sun},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00063}
}