StubCoder : Automated Generation and Repair of Stub Code for Mock Objects
Open Access
- 24 November 2023
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Software Engineering and Methodology
- Vol. 33 (1) , 1-31
Abstract
Mocking is an essential unit testing technique for isolating the class under test from its dependencies. Developers often leverage mocking frameworks to develop stub code that specifies the behaviors of mock objects. However, developing and maintaining stub code is labor-intensive and error-prone. In this article, we present StubCoder to automatically generate and repair stub code for regression testing. StubCoder implements a novel evolutionary algorithm that synthesizes test-passing stub code guided by the runtime behavior of test cases. We evaluated our proposed approach on 59 test cases from 13 open source projects. Our evaluation results show that StubCoder can effectively generate stub code for incomplete test cases without stub code and repair obsolete test cases with broken stub code.Keywords
All Related Versions
Funding Information
- National Science Foundation of China (61932021)
- Hong Kong Research Grant Council/General Research Fund (16205821)
- Hong Kong Research Grant Council/Research Impact Fund (R5034-18)
- Natural Sciences and Engineering Research Council of Canada Discovery Grant (RGPIN-2022-03744 and DGECR-2022-00378)
- WeBank-HKUST Joint Laboratory
This publication has 47 references indexed in Scilit:
- Generating TCP/UDP network data for automated unit test generation2015
- Improving Multi-Objective Test Case Selection by Injecting Diversity in Genetic AlgorithmsIEEE Transactions on Software Engineering, 2014
- WATER2011
- A fast and elitist multiobjective genetic algorithm: NSGA-IIIEEE Transactions on Evolutionary Computation, 2002
- Mock objectsIEEE Software, 2002
- Evolutionary test environment for automatic structural testingInformation and Software Technology, 2001
- A guided tour to approximate string matchingACM Computing Surveys, 2001
- A Comparison of Selection Schemes Used in Evolutionary AlgorithmsEvolutionary Computation, 1996
- The program dependence graph and its use in optimizationACM Transactions on Programming Languages and Systems, 1987
- A technique for computer detection and correction of spelling errorsCommunications of the ACM, 1964