重新审视并改进检索增强的深度断言生成
Revisiting and Improving Retrieval-Augmented Deep Assertion Generation
AI总结:
本文深入分析了检索与深度学习集成方法在断言生成中的局限性,并提出检索-编辑方法EditAS,通过检索相似焦点测试并自动编辑原型断言,在两个大规模数据集上显著提升了准确率和BLEU分数。
摘要:
单元测试用于验证被测单元的正确性,已成为软件开发过程中不可或缺的活动。一个单元测试由驱动被测单元进入特定状态的测试前缀和规定该状态下行为的测试预言(例如断言)组成。为减少单元测试中的人工工作量,Yu等人提出了一种集成方法(简称integration),将信息检索(IR)与基于深度学习的方法相结合,为单元测试生成断言。尽管该方法前景良好,但关于integration为何有效或无效、在何处有效或无效,仍存在知识空白。本文对integration的有效性进行了深入分析。分析结果表明:1)integration的整体性能主要归功于其在检索断言方面的成功;2)integration难以理解检索到的焦点测试(focal-test,包括测试前缀和被测单元)与输入焦点测试之间的语义差异;3)integration仅限于特定类型的编辑操作,无法处理token的添加或删除。为提高断言生成的有效性,本文提出了一种新颖的检索-编辑方法,名为EditAS。具体而言,EditAS首先从预定义语料库中检索相似的焦点测试,并将其断言视为原型。然后,EditAS复用原型中的信息并自动编辑原型。EditAS比integration更具泛化能力。我们在两个大规模数据集上进行了实验,实验结果表明EditAS优于最先进的方法,在准确率和BLEU分数上分别平均提高了10.00%-87.48%和3.30%-42.65%。
英文摘要:
Unit testing validates the correctness of the unit under test and has become an essential activity in software development process. A unit test consists of a test prefix that drives the unit under test into a particular state, and a test oracle (e.g., assertion), which specifies the behavior in that state. To reduce manual efforts in conducting unit testing, Yu et al. proposed an integrated approach (integration for short), combining information retrieval (IR) with a deep learning-based approach, to generate assertions for a unit test. Despite promising, there is still a knowledge gap as to why or where integration works or does not work. In this paper, we describe an in-depth analysis of the effectiveness of integration. Our analysis shows that: 1) The overall performance of integration is mainly due to its success in retrieving assertions. 2) integration struggles to understand the semantic differences between the retrieved focal-test (focal-test includes a test prefix and a unit under test) and the input focal-test; 3) integration is limited to specific types of edit operations and cannot handle token addition or deletion. To improve the effectiveness of assertion generation, this paper proposes a novel retrieve-and-edit approach named EditAS. Specifically, EditAS first retrieves a similar focal-test from a pre-defined corpus and treats its assertion as a prototype. Then, EditAS reuses the information in the prototype and edits the prototype automatically. EditAS is more generalizable than integration. We conduct experiments on two large-scale datasets and experimental results demonstrate that EditAS outperforms the state-of-the-art approaches, with an average improvement of 10.00%-87.48% and 3.30%-42.65% in accuracy and BLEU score, respectively.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。