StubCoder:Mock对象桩代码的自动生成与修复
StubCoder: Automated Generation and Repair of Stub Code for Mock Objects
AI总结:
针对单元测试中Mock对象桩代码编写与维护成本高、易出错的问题,本文提出StubCoder,利用进化算法依据测试运行时行为自动生成并修复桩代码,并在13个开源项目的59个测试用例上验证了有效性。
摘要:
Mock(模拟)是一种重要的单元测试技术,用于将被测类(CUT)与其依赖项隔离开来。开发者通常利用Mock框架编写桩代码,以规定Mock对象的行为。然而,开发和维护桩代码既耗费人力又容易出错。本文提出StubCoder,用于为回归测试自动生成和修复桩代码。StubCoder实现了一种新颖的进化算法,该算法在测试用例运行时行为的引导下,合成能够通过测试的桩代码。我们在来自13个开源项目的59个测试用例上评估了所提出的方法。评估结果表明,StubCoder能够有效地为没有桩代码的不完整测试用例生成桩代码,并修复桩代码已损坏的过时测试用例。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。