Prompt Coverage Adequacy

📄 arXiv: 2607.02057 📥 PDF

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

分类: cs.SE, cs.AI

发布日期: 2026-07-05


💡 一句话要点

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

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

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

📋 核心要点

  1. 现有测试方法在LLM驱动的软件开发中面临挑战,传统的代码覆盖标准无法有效指导基于提示的测试。
  2. 本文提出Prompt Coverage Adequacy,通过衡量测试套件对提示需求的满足程度,来优化代码生成的测试过程。
  3. 实验结果显示,Prompt Coverage在故障检测方面比传统方法提高了30%以上,验证了其有效性和实用性。

📝 摘要(中文)

近年来,大型语言模型(LLMs)和自主智能体在软件开发中引入了新的抽象层次,重点从编写精确程序转向表达意图和目标。这一范式转变带来了新的挑战,尤其是在如何指导测试方面。为此,本文提出了一种新的覆盖标准——Prompt Coverage Adequacy,旨在支持基于任务描述生成的代码测试。该标准通过利用LLMs的注意力机制,衡量给定测试套件满足提示中表达的需求的程度。实验结果表明,Prompt Coverage在故障检测有效性方面表现出色,能够比传统代码覆盖率多发现超过30%的故障,显示出其在LLM驱动软件开发中的潜在应用价值。

🔬 方法详解

问题定义:本文旨在解决在LLM驱动的软件开发中,传统测试方法无法有效指导基于提示的代码生成测试的问题。现有方法在适应新范式时存在局限性,无法充分利用LLMs的特性。

核心思路:提出Prompt Coverage Adequacy作为一种新的覆盖标准,专注于提示的有效性,利用LLMs的注意力机制来评估测试套件的质量。通过这种方式,能够更好地满足提示中表达的需求,从而提高测试的有效性。

技术框架:整体架构包括提示输入、LLM生成代码、测试套件生成和覆盖评估四个主要模块。首先,输入提示被传递给LLM,生成相应的代码;然后,基于Prompt Coverage标准生成测试套件,最后评估测试套件的覆盖效果。

关键创新:最重要的创新点在于将注意力机制应用于测试覆盖评估,形成了一种新的覆盖标准,能够更好地适应LLM驱动的开发环境。这与传统的代码覆盖标准有本质区别,后者主要关注代码行的执行情况。

关键设计:在参数设置上,采用了注意力增强的方法来提升Prompt Coverage的评估效果。损失函数设计上,结合了覆盖率和故障检测的双重目标,以确保测试的全面性和有效性。

📊 实验亮点

实验结果表明,Prompt Coverage在故障检测方面的有效性显著高于传统代码覆盖,能够多发现超过30%的故障。这一发现强调了Prompt Coverage在指导测试生成中的重要性,为LLM驱动的软件开发提供了新的测试标准。

🎯 应用场景

该研究的潜在应用领域包括自动化软件测试、代码生成工具和智能编程助手等。通过引入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.