StubCoder: Automated Generation and Repair of Stub Code for Mock Objects
Authors:
Preprint
Abstract
Mocking is an essential unit testing technique for isolating the class under test (CUT) 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 paper, 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
This publication has 42 references indexed in Scilit:
- Generating Mock Skeletons for Lightweight Web-Service Testing2019
- Comprehending Test Code: An Empirical Study2019
- Mock objects for testing java systemsEmpirical Software Engineering, 2018
- Ultra-Large Repair Search Space with Automatically Mined Templates: The Cardumen Mode of Astor2018
- Introduction to Software Testing2008
- SCARPE: A Technique and Tool for Selective Capture and Replay of Program Executions2007
- Tournament versus fitness uniform selection2005
- Multi-objective optimization by genetic algorithms: a review2002
- A fast and elitist multiobjective genetic algorithm: NSGA-IIIEEE Transactions on Evolutionary Computation, 2002
- Evolutionary test environment for automatic structural testingInformation and Software Technology, 2001