paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Nuances are the Key: Unlocking ChatGPT to Find Failure-Inducing Tests with Differential Prompting

细微差异是关键:通过差分提示解锁 ChatGPT 寻找引发失败的测试
ASE 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)2023匹配度 4/10 · 论文将 ChatGPT 用于自动发现失败诱导测试用例,属于 LLM 辅助软件测试/调试,与用户核心关注的静态分析、形式化验证、浮点程序分析或贝叶斯程序分析交叉较弱;其差分提示也偏提示词技巧,而非 Agentic 静态分析或理论形式化。引用 84 inbox
Tsz-On Li, Wenxi Zong, Yibo Wang, Haoye Tian, Ying Wang, Shing-Chi Cheung, Jeff Kramer
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出差分提示,引导 ChatGPT 关注正确与缺陷代码的细微差异,以发现引发失败的测试用例。

自动检测软件失败需要在大搜索空间中找到包含触发故障输入与错误执行断言的失败引发测试用例。本文研究 ChatGPT 等大语言模型能否解决该挑战,发现其直接生成失败引发测试的成功率较低(28.8%)。作者观察到,ChatGPT 在缺陷代码与正确版本相似时能够推断代码意图,于是提出 Differential Prompting:先利用推断意图合成可编译代码,再基于给定版本与合成代码之间的细微差异构造提示,引导模型生成失败引发测试。在 Quixbugs 与 Codeforces 上的评估显示,该方法成功率分别为 75.0% 和 66.7%,优于常规 ChatGPT 提示与 Pynguin 基线。

问题
如何自动找到包含触发故障输入与错误执行断言的失败引发测试用例,并提升 LLM 在此任务上的低成功率。
方法
提出 Differential Prompting:利用 ChatGPT 推断缺陷程序意图并合成可编译代码,再基于原程序与合成代码的细微差异构造提示。
评估
在 Quixbugs 和 Codeforces 上与常规 ChatGPT 提示及 Pynguin 比较;成功率分别达 75.0% 与 66.7%,优于最佳基线 2.6 倍和 4.0 倍。
原文摘要(Abstract)

Automated detection of software failures is an important but challenging software engineering task. It involves finding in a vast search space the failure-inducing test cases that contain an input triggering the software fault and an oracle asserting the incorrect execution. We are motivated to study how far this outstanding challenge can be solved by recent advances in large language models (LLMs) such as ChatGPT. However, our study reveals that ChatGPT has a relatively low success rate (28.8%) in finding correct failure-inducing test cases for buggy programs. A possible conjecture is that finding failure-inducing test cases requires analyzing the subtle differences (nuances) between the tokens of a program's correct version and those for its buggy version. When these two versions have similar sets of tokens and attentions, ChatGPT is weak in distinguishing their differences. We find that ChatGPT can successfully generate failure-inducing test cases when it is guided to focus on the nuances. Our solution is inspired by an interesting observation that ChatGPT could infer the intended functionality of buggy code if it is similar to the correct version. Driven by the inspiration, we develop a novel technique, called Differential Prompting, to effectively find failure-inducing test cases with the help of the compilable code synthesized by the inferred intention. Prompts are constructed based on the nuances between the given version and the synthesized code. We evaluate Differential Prompting on Quixbugs (a popular benchmark of buggy programs) and recent programs published at Codeforces (a popular programming contest portal, which is also an official benchmark of ChatGPT). We compare Differential Prompting with two baselines constructed using conventional ChatGPT prompting and Pynguin (the state-of-the-art unit test generation tool for Python programs). Our evaluation results show that for programs of Quixbugs, Differential Prompting can achieve a success rate of 75.0% in finding failure-inducing test cases, outperforming the best baseline by 2.6X. For programs of Codeforces, Differential Prompting's success rate is 66.7%, outperforming the best baseline by 4.0X.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{LiZWTWCK23,
  title = {Nuances are the Key: Unlocking ChatGPT to Find Failure-Inducing Tests with Differential Prompting},
  author = {Tsz-On Li and Wenxi Zong and Yibo Wang and Haoye Tian and Ying Wang and Shing-Chi Cheung and Jeff Kramer},
  booktitle = {ASE},
  year = {2023},
  doi = {10.1109/ase56229.2023.00089}
}