arXiv:2604.05159cs.SEcs.AI2026-04

用好奇心驱动规划提升大模型测试生成效果

Planning to Explore: Curiosity-Driven Planning for LLM Test Generation

  • 将代码分支视为未知环境,用覆盖率地图引导探索
  • 在三个大模型上实现51%-77%更高分支覆盖率
  • 适合需要深度测试覆盖的软件工程与AI测试场景

大语言模型在代码生成之外已扩展至测试生成与评估。随着代码库规模与复杂度增加,自动化测试生成需求日益增长。现有基于LLM的测试生成方法依赖于最大化即时覆盖率的方法,这种贪婪策略在需要前置设置才能触及深层分支的代码中会陷入瓶颈。受贝叶斯探索启发,我们将程序分支结构视为未知环境,将不断演化的覆盖率地图作为模型已发现内容的代理概率后验。提出CovQValue方法:将覆盖率地图反馈给LLM,平行生成多样候选计划,并通过LLM估算的Q值选择最富信息量的计划,以平衡即时分支发现与未来可达性。该方法在TestGenEval Lite上超越贪婪选择,在三个主流大模型上实现51%-77%更高的分支覆盖率,且在77%-84%的目标中胜出。此外,我们构建了迭代测试生成基准RepoExploreBench,结果达到40%-74%的提升。这些结果表明,好奇心驱动的规划方法具有潜力,可借助序列交互更有效地发现程序行为。

原文摘要 · Abstract (English)

The use of LLMs for code generation has naturally extended to code testing and evaluation. As codebases grow in size and complexity, so does the need for automated test generation. Current approaches for LLM-based test generation rely on strategies that maximize immediate coverage gain, a greedy approach that plateaus on code where reaching deep branches requires setup steps that individually yield zero new coverage. Drawing on principles of Bayesian exploration, we treat the program's branch structure as an unknown environment, and an evolving coverage map as a proxy probabilistic posterior representing what the LLM has discovered so far. Our method, CovQValue, feeds the coverage map back to the LLM, generates diverse candidate plans in parallel, and selects the most informative plan by LLM-estimated Q-values, seeking actions that balance immediate branch discovery with future reachability. Our method outperforms greedy selection on TestGenEval Lite, achieving 51-77% higher branch coverage across three popular LLMs and winning on 77-84% of targets. In addition, we build a benchmark for iterative test generation, RepoExploreBench, where they achieve 40-74%. These results show the potential of curiosity-driven planning methods for LLM-based exploration, enabling more effective discovery of program behavior through sequential interaction

测试生成大模型探索算法

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。