arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2605.07957cs.SE
收藏

通过检索知识实现相似模式注释的LLM基于测试代码故障定位

Similar Pattern Annotation via Retrieval Knowledge for LLM-Based Test Code Fault Localization

University of Ottawa(渥太华大学);Research Ireland Lero Centre, University of Limerick(利默里克大学LERO研究中心);Huawei Technologies Co., Ltd.(华为技术有限公司)

Golnaz Gharachorlu, Mahsa Panahandeh, Lionel C. Briand, Ruifeng Gao, Ruiyuan Wan

AI总结:

本文提出SPARK框架,通过整合CI环境积累的调试知识,提升LLM在测试代码故障定位中的效率,实验表明其在复杂测试用例中能更准确识别故障位置。

摘要:

软件故障仍然是现代软件开发中的主要挑战,识别导致故障的代码元素是一项耗时的调试任务。尽管大量研究集中在被测系统(SUT)的故障定位,但故障也可能源自故障的系统测试脚本。这个问题被称为测试代码故障定位(TCFL),尽管在持续集成(CI)环境中频繁执行大型测试套件,但其关注度较低。TCFL特别具有挑战性,因为它通常在黑盒条件下操作,依赖有限的诊断信号如错误信息和部分日志,并涉及大型系统级测试脚本,扩大了故障定位的搜索空间。在本文中,我们提出SPARK,一个将连续集成(CI)环境积累的调试知识整合到基于大语言模型(LLM)的TCFL中的框架。给定一个新观察到的失败测试用例,SPARK从调试知识库中检索相似的故障标记测试用例,并根据其与之前观察到的故障模式的相似性,选择性地注释失败测试中的可疑行。这些注释指导LLM的推理,同时保持可扩展性和避免朴素检索增强方法中常见的提示长度爆炸问题。我们评估了SPARK在三个工业数据集上的表现,这些数据集包含来自不同软件产品的实际故障Python测试用例。结果表明,与现有的基于LLM的TCFL基线相比,SPARK在保持可比的推理成本和令牌使用量的同时,持续提高了故障定位的有效性。特别是,该方法通过识别复杂测试用例中的多个故障位置,推动了该领域的前沿。

英文摘要:

Software failures remain a major challenge in modern software development, and identifying the code elements responsible for failures is a time-consuming debugging task. While extensive research has focused on fault localization in the system under test (SUT), failures can also originate from faulty system test scripts. This problem, known as Test Code Fault Localization (TCFL), has received significantly less attention despite its importance in continuous integration (CI) environments where large test suites are executed frequently. TCFL is particularly challenging because it typically operates under black-box conditions, relies on limited diagnostic signals such as error messages and partial logs, and involves large system-level test scripts that expand the fault localization search space. In this paper, we propose SPARK, a framework that integrates accumulated debugging knowledge from continuous integration (CI) environments into Large Language Model (LLM)-based TCFL. Given a newly observed failing test case, SPARK retrieves similar fault-labeled test cases from a debugging knowledge corpus and selectively annotates suspicious lines of the failing test based on their similarity to previously observed fault patterns. These annotations guide the LLM's reasoning while maintaining scalability and avoiding the prompt-length explosion common to naive retrieval-augmented approaches. We evaluate SPARK on three industrial datasets containing real-world faulty Python test cases from different software products. The results show that SPARK consistently improves fault localization effectiveness compared to the existing LLM-based TCFL baseline while maintaining comparable inference cost and token usage. In particular, the approach advances the state of the art by identifying more correct faulty locations in complex test cases containing multiple faults.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑