Most modern software systems are characterized by a high number of components whose interactions can affect and complicate testing activities. During testing, developers can account for the interactions by isolating the code under test using test doubles and stubbings. During the evolution of a test suite, stubbings might become unnecessary, and developers should remove unnecessary stubbings, as their definitions can introduce unreliable test results in future versions of the test suite. Unfortunately, removing unnecessary stubbings is still a manual task that can be complex and time-consuming. To help developers in this task, we propose ARUS, a technique to automatically remove unnecessary stubbings from test suites. Given a software project and its test suite, the technique executes the tests to identify unnecessary stubbings and then removes them using different approaches based on the characteristics of the stubbings. We performed an empirical evaluation based on 128 Java projects that use Mockito for stubbing and contain 280 stubbing definitions that lead to 1,529 unnecessary stubbings. Overall, our technique provides a solution for 276 of the definitions (98.6% resolution rate), ARUS' time cost is negligible, and, on average, the technique's changes introduce a limited increase in code complexity. We submitted ARUS' changes to the projects through pull requests and 83 resolutions are already merged.
翻译:大多数现代软件系统具有大量组件,其交互可能影响并复杂化测试活动。在测试过程中,开发者可通过使用测试替身和桩代码隔离被测代码来应对这些交互。随着测试套件的演化,部分桩代码可能变得不再必要,开发者应移除这些不必要的桩代码,因其定义可能导致测试套件在未来版本中产生不可靠的测试结果。然而,移除不必要的桩代码目前仍是手动任务,过程复杂且耗时。为协助开发者完成此任务,我们提出ARUS技术,用于自动移除测试套件中不必要的桩代码。给定软件项目及其测试套件,该技术通过执行测试来识别不必要的桩代码,随后根据桩代码特性采用不同方法将其移除。我们基于128个使用Mockito进行桩代码注入的Java项目进行了实证评估,这些项目包含280个桩代码定义,共产生1,529个不必要的桩代码实例。总体而言,我们的技术成功解决了其中276个定义的问题(解决率达98.6%),ARUS的时间开销可忽略不计,且技术引入的代码修改平均仅导致有限的复杂度增加。我们通过拉取请求向相关项目提交了ARUS的修改方案,目前已有83项解决方案被合并采纳。