所见即所得:基于注意力的自引导自动单元测试生成
What You See Is What You Get: Attention-based Self-guided Automatic Unit Test Generation
AI总结:
本文提出两阶段 AUGER 框架,利用注意力机制先检测缺陷倾向,再依据关键信息自引导生成单元测试,在多个基准上显著提升缺陷检测与错误触发效果。
摘要:
软件缺陷严重影响软件功能,并可能造成巨大损失。近年来,研究者提出了许多基于 AI 的缺陷检测方法,这些方法可分为两类:软件缺陷预测和自动单元测试生成。尽管这些方法在软件缺陷检测方面取得了显著进展,但在实际应用中仍存在若干局限,包括预测模型置信度较低以及单元测试模型效率不高。为解决这些局限,我们提出一种 WYSIWYG(即 What You See Is What You Get,所见即所得)方法:基于注意力的自引导自动单元测试生成(Attention-based Self-guided Automatic Unit Test GenERation,AUGER),该方法包含缺陷检测和错误触发两个阶段。在前一阶段,AUGER 首先检测缺陷发生的倾向;随后在后一阶段,借助前一阶段获得的关键信息,引导生成用于触发此类错误的单元测试。为评估 AUGER 的有效性,我们在广泛使用的数据集(即 Bears、Bugs.jar 和 Defects4J)上开展大规模实验,并与最先进(SOTA)方法进行比较。AUGER 在缺陷检测的 F1 分数和精确率上分别实现了 4.7% 至 35.3% 和 17.7% 至 40.4% 的显著提升;在单元测试生成方面,相比 SOTA 方法能够多触发 23 至 84 个错误。此外,我们还通过从真实世界项目中收集一个新数据集开展进一步研究,以验证其在实际使用中的泛化能力。
英文摘要:
Software defects heavily affect software's functionalities and may cause huge losses. Recently, many AI-based approaches have been proposed to detect defects, which can be divided into two categories: software defect prediction and automatic unit test generation. While these approaches have made great progress in software defect detection, they still have several limitations in practical application, including the low confidence of prediction models and the inefficiency of unit testing models. To address these limitations, we propose a WYSIWYG (i.e., What You See Is What You Get) approach: Attention-based Self-guided Automatic Unit Test GenERation (AUGER), which contains two stages: defect detection and error triggering. In the former stage, AUGER first detects the proneness of defects. Then, in the latter stage, it guides to generate unit tests for triggering such an error with the help of critical information obtained by the former stage. To evaluate the effectiveness of AUGER, we conduct a large-scale experiment by comparing with the state-of-the-art (SOTA) approaches on the widely used datasets (i.e., Bears, Bugs.jar, and Defects4J). AUGER makes great improvements by 4.7% to 35.3% and 17.7% to 40.4% in terms of F1-score and Precision in defect detection, and can trigger 23 to 84 more errors than SOTAs in unit test generation. Besides, we also conduct a further study to verify the generalization in practical usage by collecting a new dataset from real-world projects.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。