arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2209.11515cs.SE
收藏

大语言模型是少样本测试者:探索基于LLM的通用缺陷复现

Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproduction

Sungmin Kang, Juyeon Yoon, Shin Yoo

AI总结:

针对现有测试生成技术难以从通用缺陷报告复现缺陷的问题,提出基于大语言模型的LIBRO框架,通过后处理排序测试有效性,在Defects4J等基准上取得良好效果,可提升开发效率。

摘要:

已有许多自动化测试生成技术被开发出来,以辅助开发人员编写测试用例。为实现完全自动化,现有多数技术要么致力于提升覆盖率,要么生成探索性输入。然而,现有测试生成技术大多难以实现更具语义性的目标,例如生成测试用例来复现给定的缺陷报告。但缺陷复现十分重要:我们的实证研究显示,开源代码仓库中因问题新增的测试用例数量,约占对应项目测试套件总规模的28%。\n同时,由于难以将缺陷报告中的预期程序语义转化为测试预言,现有的故障复现技术往往仅能处理程序崩溃类问题,而这只是所有缺陷报告中的一小部分。为实现从通用缺陷报告自动生成测试用例,我们提出LIBRO(一种基于大语言模型的框架),大语言模型已被证明具备执行代码相关任务的能力。由于大语言模型本身无法执行存在缺陷的目标代码,我们重点研究后处理步骤,用于判断大语言模型何时有效,并根据生成测试的有效性对其排序。\n我们对LIBRO的评估显示,在被广泛研究的Defects4J基准上,LIBRO可为33%的研究用例(750个中的251个)生成故障复现测试用例,其中149个缺陷的复现测试排在首位。为降低数据污染的影响,我们还使用31份在LLM训练数据收集结束后提交的缺陷报告对LIBRO进行评估:LIBRO可为32%的研究缺陷报告生成缺陷复现测试。总体而言,结果表明LIBRO能够通过从缺陷报告自动生成测试用例,显著提升开发人员效率。

英文摘要:

Many automated test generation techniques have been developed to aid developers with writing tests. To facilitate full automation, most existing techniques aim to either increase coverage, or generate exploratory inputs. However, existing test generation techniques largely fall short of achieving more semantic objectives, such as generating tests to reproduce a given bug report. Reproducing bugs is nonetheless important, as our empirical study shows that the number of tests added in open source repositories due to issues was about 28% of the corresponding project test suite size. Meanwhile, due to the difficulties of transforming the expected program semantics in bug reports into test oracles, existing failure reproduction techniques tend to deal exclusively with program crashes, a small subset of all bug reports. To automate test generation from general bug reports, we propose LIBRO, a framework that uses Large Language Models (LLMs), which have been shown to be capable of performing code-related tasks. Since LLMs themselves cannot execute the target buggy code, we focus on post-processing steps that help us discern when LLMs are effective, and rank the produced tests according to their validity. Our evaluation of LIBRO shows that, on the widely studied Defects4J benchmark, LIBRO can generate failure reproducing test cases for 33% of all studied cases (251 out of 750), while suggesting a bug reproducing test in first place for 149 bugs. To mitigate data contamination, we also evaluate LIBRO against 31 bug reports submitted after the collection of the LLM training data terminated: LIBRO produces bug reproducing tests for 32% of the studied bug reports. Overall, our results show LIBRO has the potential to significantly enhance developer efficiency by automatically generating tests from bug reports.

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

↑