Automated Detection and Refactoring of Mock Clones in Java Projects
Mocking is an essential technique in unit testing, allowing developers to isolate dependencies for more focused and reliable tests. However, repetitive patterns of mock creation, termed \textit{mock clones}, introduce significant redundancy, increasing maintenance costs, reducing readability, and complicating updates in test code. To address these challenges, our research investigates the detection and refactoring of mock clones, aiming to improve the maintainability and efficiency of test code in large software projects.
We began with an empirical study of mocking framework usage across open-source Java projects, revealing widespread adoption of frameworks like Mockito, along with patterns and practices that commonly lead to mock clones. Following this, we analyzed the prevalence and impact of mock clones across six representative projects, identifying significant redundancy and demonstrating the limitations of traditional clone detection tools. Manual refactoring of identified mock clones reduced thousands of redundant lines, with developers responding positively to these improvements.
Building on these foundational studies, our ongoing work seeks to develop automated tools for detecting and refactoring mock clones, enabling systematic and scalable improvements to test code. This research offers both empirical insights and practical solutions that contribute toward automated test code maintenance, advancing sustainable software testing practices.
Tue 29 AprDisplayed time zone: Eastern Time (US & Canada) change
14:00 - 15:00 | Session 3: Maintenance (talks and panel)Doctoral Symposium at 212 Chair(s): Alexander Serebrenik Eindhoven University of Technology | ||
14:00 6mTalk | Concern-based Management of Software Design Complexity Doctoral Symposium Jason Lefever Drexel University | ||
14:06 6mTalk | Mitigating Waste That Tacitly Accrues in Continuous Integration Pipelines Doctoral Symposium Nimmi Rashinika Weeraddana University of Waterloo Pre-print | ||
14:12 6mTalk | Automated Detection and Refactoring of Mock Clones in Java Projects Doctoral Symposium Gengwu Zhao Stevens Institute of Technology | ||
14:18 6mTalk | Practical Preprocessing of Logs at Scale Doctoral Symposium JianChen Zhao University of Waterloo | ||
14:24 6mTalk | Bridging the Gap Between Log Parsing Techniques and Practitioners: Challenges and Solutions Doctoral Symposium Hetong Dai University of Waterloo | ||
14:30 30mPanel | Panel: Maintenance Doctoral Symposium Sridhar Chimalakonda Indian Institute of Technology Tirupati, Wesley Assunção Johannes Kepler University Linz, Hetong Dai University of Waterloo, Jason Lefever Drexel University, Nimmi Weeraddana University of Waterloo, JianChen Zhao University of Waterloo, Gengwu Zhao Stevens Institute of Technology |