Test case generation is an important activity, yet a time-consuming and laborious task. Recently, AthenaTest -- a deep learning approach for generating unit test cases -- is proposed. However, AthenaTest can generate less than one-fifth of the test cases correctly, due to a lack of assertion knowledge and test signature verification. In this paper, we propose A3Test, a DL-based test case generation approach that is augmented by assertion knowledge with a mechanism to verify naming consistency and test signatures. A3Test leverages the domain adaptation principles where the goal is to adapt the existing knowledge from an assertion generation task to the test case generation task. We also introduce a verification approach to verify naming consistency and test signatures. Through an evaluation of 5,278 focal methods from the Defects4j dataset, we find that our A3Test (1) achieves 147% more correct test cases and 15% more method coverage, with a lower number of generated test cases than AthenaTest; (2) still outperforms the existing pre-trained models for the test case generation task; (3) contributes substantially to performance improvement via our own proposed assertion pre-training and the verification components; (4) is 97.2% much faster while being more accurate than AthenaTest.
翻译:测试案例生成是一项重要活动, 但却是一个耗时费时和费力的任务。 最近, 提议了 AthenaTest -- -- 生成单位测试案例的深度学习方法 -- -- AthenaTest -- -- 来生成单位测试案例。 但是, AthenaTest 由于缺乏确认知识和测试签名的核查, 能够正确地生成不到五分之一的测试案例。 在本文中, 我们提议A3Test, 一种基于DL的测试案例生成方法, 以维护知识的方式, 并辅之以一个用于核查命名一致性和测试签名的机制, 以强化基于DL的测试案例生成方法。 A3Test 利用了域适应原则, 目的是将现有知识从主张生成任务中调整到测试案例生成任务中。 我们还采用了一种核查方法来核查命名的一致性和测试签名。 通过对来自Deffects4j数据集的5 278个焦点方法进行评估, 我们发现我们的A3Test(1) 能够实现147%的正确测试案例和15%以上的方法覆盖范围, 而生成的测试案例数量比 Athon; (2) 仍然比测试案例生成任务的现有培训前模式差得多; (3) 通过我们提议的预培训前和核查组成部分大大有助于改进业绩。