当前位置: X-MOL 学术IEEE Trans. Softw. Eng. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Refactoring Test Smells With JUnit 5: Why Should Developers Keep Up-to-Date?
IEEE Transactions on Software Engineering ( IF 6.5 ) Pub Date : 5-5-2022 , DOI: 10.1109/tse.2022.3172654
Elvys Soares 1 , Marcio Ribeiro 2 , Rohit Gheyi 3 , Guilherme Amaral 4 , Andre Medeiros Santos 5
Affiliation  

Test smells are symptoms in the test code that indicate possible design or implementation problems. Previous research demonstrated their harmfulness and the developers’ acknowledgment of test smells’ effects, prevention, and refactoring strategies. Test automation frameworks are constantly evolving, and the JUnit, one of the most used ones for Java projects, has its version 5 available since late 2017. However, we do not know the extent to which developers use the newly introduced features and whether such features indeed help refactor existing test code to remove test smells. This article conducts a mixed-method study investigation to minimize these knowledge gaps. Our study consists of three parts. First, we evaluate the usage of this framework and its features by analyzing the source code of 485 popular Java open-source projects on GitHub that use JUnit. We found that 15.9% of these projects use the JUnit 5 library. We also found that, from 17 new features detected in use, only 3 (i.e., 17.6%) are responsible for more than 70% of usages, limiting optimized propositions to test code creation and maintenance. Second, after identifying features in the JUnit 5 framework that could be considered to test smells removal and prevention, we use these features to propose novel refactorings. In particular, we present refactorings based on 7 introduced JUnit 5 features that help to remove 13 test smells, such as Assertion Roulette, Test Code Duplication, and Conditional Test Logic. Third, to evaluate our refactorings with the opinions of experienced developers, we (i) survey 212 developers for their preferences and comments about our refactorings, corroborating the benefits of our proposals and raising community feedback on JUnit 5 features, and (ii) we refactor actual test code from popular GitHub Java projects and submit 38 Pull Requests, reaching a 94% acceptance rate among respondents. As implications of our study, we alert the software testing community (i.e., practitioners and researchers) to the need to study the JUnit 5 features to effectively remove and prevent test smells. To better assist this process, we give directions on how test smells can be refactored using such features.

中文翻译:


JUnit 5 重构测试的味道:为什么开发人员应该保持最新状态?



测试气味是测试代码中的症状,表明可能存在设计或实现问题。先前的研究证明了它们的危害性以及开发人员对测试气味的影响、预防和重构策略的认可。测试自动化框架在不断发展,JUnit 是 Java 项目中最常用的框架之一,自 2017 年底以来已经推出了第 5 版。但是,我们不知道开发人员使用新引入的功能的程度以及这些功能是否可用确实有助于重构现有的测试代码以消除测试气味。本文进行了一项混合方法研究调查,以尽量减少这些知识差距。我们的研究由三个部分组成。首先,我们通过分析 GitHub 上 485 个使用 JUnit 的流行 Java 开源项目的源代码来评估该框架的使用及其功能。我们发现这些项目中有 15.9% 使用 JUnit 5 库。我们还发现,在使用中检测到的 17 个新功能中,只有 3 个(即 17.6%)占了 70% 以上的使用量,限制了测试代码创建和维护的优化建议。其次,在确定 JUnit 5 框架中可用于测试异味消除和预防的功能后,我们使用这些功能提出新颖的重构。特别是,我们提出了基于 7 个引入的 JUnit 5 功能的重构,这些功能有助于消除 13 个测试异味,例如断言轮盘、测试代码重复和条件测试逻辑。 第三,为了根据经验丰富的开发人员的意见评估我们的重构,我们 (i) 调查 212 名开发人员,了解他们对我们重构的偏好和评论,证实我们提案的好处并提高社区对 JUnit 5 功能的反馈,以及 (ii) 我们重构来自热门 GitHub Java 项目的实际测试代码,并提交了 38 个 Pull Request,受访者的接受率达到 94%。作为我们研究的启示,我们提醒软件测试社区(即从业者和研究人员)需要研究 JUnit 5 功能,以有效消除和防止测试异味。为了更好地协助这一过程,我们给出了如何使用此类功能重构测试气味的指导。
更新日期:2024-08-28
down
wechat
bug