Prompt Coverage Adequacy

📄 arXiv: 2607.02057v1 📥 PDF

作者: Florian Tambon, Michael Konstantinou, Cedric Richter, Charles Chenouard, Mark Harman, Mike Papadakis

分类: cs.SE, cs.AI

发布日期: 2026-07-02


💡 一句话要点

提出Prompt Coverage Adequacy以解决LLM驱动软件开发测试问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 软件测试 覆盖标准 故障检测 自动化测试 智能编程

📋 核心要点

  1. 当前软件测试方法在LLM驱动开发中面临挑战,传统的代码覆盖标准无法有效指导基于提示的测试。
  2. 本文提出Prompt Coverage Adequacy,作为一种新型覆盖标准,旨在通过LLM的注意力机制评估测试套件的有效性。
  3. 实验结果显示,Prompt Coverage在故障检测方面表现优异,能够比传统方法多发现30%以上的故障,提升了测试的有效性。

📝 摘要(中文)

近年来,大型语言模型(LLMs)和自主智能体在软件开发中引入了新的抽象层次,重点从编写精确的程序转向表达意图和目标。这一范式转变带来了新的挑战,尤其是在如何指导测试方面。为此,本文提出了一种新颖的覆盖标准——Prompt Coverage Adequacy,旨在支持基于任务描述生成的代码测试。该标准类似于传统的代码覆盖,但在LLM和智能体编程的提示层面上运作,衡量测试套件满足提示中表达的需求的程度。通过对两个数据集和多个LLM的评估,结果表明,Prompt Coverage与故障检测有效性相关,能够比传统代码覆盖多发现超过30%的故障。这些发现表明,Prompt Coverage Adequacy可以为开发更适合LLM驱动软件开发的新测试指标奠定基础。

🔬 方法详解

问题定义:本文旨在解决在LLM驱动的软件开发中,如何有效测试基于提示生成的代码的问题。现有的传统代码覆盖方法无法适应这一新兴的开发模式,导致测试效果不佳。

核心思路:论文提出的Prompt Coverage Adequacy覆盖标准,通过分析LLM的注意力机制,评估测试套件对提示中需求的满足程度,从而指导测试生成。

技术框架:整体架构包括三个主要模块:1) 提示解析模块,提取提示中的需求;2) 测试生成模块,基于需求生成测试用例;3) 覆盖评估模块,利用注意力机制评估测试用例的有效性。

关键创新:最重要的创新点在于将注意力机制应用于测试覆盖评估,使得测试不仅关注代码本身,而是关注代码背后的意图和需求,这与传统方法有本质区别。

关键设计:在设计中,关键参数包括注意力权重的计算方式和测试用例生成的策略,损失函数则侧重于覆盖率与故障检测的平衡,确保生成的测试用例既能覆盖需求,又能有效发现潜在故障。

🖼️ 关键图片

img_0
img_1

📊 实验亮点

实验结果表明,Prompt Coverage在故障检测方面显著优于传统代码覆盖,能够多发现超过30%的故障。这一提升展示了Prompt Coverage在指导测试生成中的有效性,具有重要的应用前景。

🎯 应用场景

该研究的潜在应用领域包括软件开发、自动化测试和智能编程助手等。通过引入Prompt Coverage Adequacy,开发者可以更有效地测试基于LLM生成的代码,提高软件质量和开发效率,具有重要的实际价值和未来影响。

📄 摘要(原文)

In recent years, it has become increasingly evident that large language models (LLMs) and autonomous agents raise the level of abstraction in software development by shifting the focus from writing precise procedures to expressing intents and goals. This paradigm shift introduces new challenges, particularly in how testing should be guided when prompts, rather than code, become primary development artifacts. To address this challenge, we propose Prompt Coverage Adequacy, a novel coverage criterion designed to support the testing of code generated from task descriptions. Prompt Coverage Adequacy serves as an analog to traditional code coverage, but operates at the level of prompts used in LLM and agent-based programming. Specifically, it measures how well a given test suite satisfies the requirements expressed in a prompt by leveraging the attention mechanisms of LLMs. We evaluate a simple instantiation of this criterion, based on attention boosting, across two datasets and multiple LLMs. Our results demonstrate that Prompt Coverage is associated with fault-detection effectiveness and can uncover over 30+% more faults than traditional code coverage when used to guide test generation. These findings suggest that Prompt Coverage Adequacy can serve as a foundation for developing testing metrics better suited to the emerging paradigm of LLM-driven software development, addressing the limitations of classical coverage criteria in this new context.