A3Test: Assertion-Augmented Automated Test case generation

被引:8
作者
Alagarsamy, Saranya [1 ]
Tantithamthavorn, Chakkrit [1 ]
Aleti, Aldeida [1 ]
机构
[1] Monash Univ, Melbourne, Australia
基金
澳大利亚研究理事会;
关键词
Test case generation; Deep learning;
D O I
10.1016/j.infsof.2024.107565
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
Context: Test case generation is a critical yet challenging task in software development. Recently, AthenaTest - a Deep Learning (DL) approach for generating unit test cases has been proposed. However, our revisiting study reveals that AthenaTest can generate less than one-fifth of the test cases correctly, due to a lack of assertion knowledge and test signature verification. Objective: This paper introduces A3Test, a novel DL-based approach to the generation of test cases, enhanced with assertion knowledge and a mechanism to verify consistency of the name and signatures of the tests. A3Test aims to adapt domain knowledge from assertion generation to test case generation. Method: A3Test employs domain adaptation principles and introduces a verification approach to name consistency and test signatures. We evaluate its effectiveness using 5,278 focal methods from the Defects4j dataset. Results: Our findings indicate that A3Test outperforms AthenaTest and ChatUniTest. A3Test generates 2.16% to 395.43% more correct test cases, achieves 2.17% to 34.29% higher method coverage, and 25.64% higher line coverage. A3Test achieves 2.13% to 12.20% higher branch coverage, 2.22% to 12.20% higher mutation scores, and 2.44% to 55.56% more correct assertions compared to both ChatUniTest and AthenaTest respectively for one iteration. When generating multiple test cases per method A3Test still shows improvements and comparable efficacy to ChatUnitTest. A survey of developers reveals that the majority of the participants 70.51% agree that test cases generated by A3Test are more readable than those generated by EvoSuite. Conclusions: A3Test significantly enhances test case generation through its incorporation of assertion knowledge and test signature verification, contributing to the generation of correct test cases.
引用
收藏
页数:15
相关论文
共 37 条
[31]  
Site.mockito.org, 2023, About us
[32]  
Testng, 2022, About us
[33]  
Tufano M, 2021, Arxiv, DOI arXiv:2009.05617
[34]   Methods2Test: A dataset of focal methods mapped to test cases [J].
Tufano, Michele ;
Deng, Shao Kun ;
Sundaresan, Neel ;
Svyatkovskiy, Alexey .
2022 MINING SOFTWARE REPOSITORIES CONFERENCE (MSR 2022), 2022, :299-303
[35]  
Wang Yue, 2021, 2021 C EMPIRICAL MET, P8696
[36]   On Learning Meaningful Assert Statements for Unit Test Cases [J].
Watson, Cody ;
Tufano, Michele ;
Moran, Kevin ;
Bavota, Gabriele ;
Poshyvanyk, Denys .
2020 ACM/IEEE 42ND INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING (ICSE 2020), 2020, :1398-1409
[37]  
Wolf T, 2020, Arxiv, DOI arXiv:1910.03771