JMocker: Refactoring Test-Production Inheritance by Mockito

Xiao Wang, Lu Xiao, Tingting Yu, Anne Woepse, Sunny Wong

    Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

    3 Scopus citations

    Abstract

    Mocking frameworks are dedicated to creating, manipulating, and verifying the execution of "faked"objects in unit testing. This helps developers to overcome the challenge of high inter-dependencies among software units. Despite the various benefits offered by existing mocking frameworks, developers often create a subclass of the dependent class and mock its behavior through method overriding. However, this requires tedious implementation and compromises the design quality of unit tests. We contribute a refactoring tool as an Eclipse Plugin, named JMocker, to automatically identify and replace the usage of inheritance by using Mockito - a well received mocking framework for Java projects. We evaluate JMocker on four open source projects and successfully refactored 214 cases in total. The evaluation results show that our framework is efficient, applicable to different projects, and preserves test behaviors. According to the feedback of six real-life developers, JMocker improves the design quality of test cases. JMocker is available at https://github.com/wx930910/JMocker. The tool demo can be found at https://youtu.be/HFoA2ZKCoxM.

    Original languageEnglish
    Title of host publicationProceedings - 2022 ACM/IEEE 44th International Conference on Software Engineering
    Subtitle of host publicationCompanion Proceedings, ICSE-Companion 2022
    Pages125-129
    Number of pages5
    ISBN (Electronic)9781665495981
    DOIs
    StatePublished - 2022
    Event44th ACM/IEEE International Conference on Software Engineering: Companion, ICSE-Companion 2022 - Pittsburgh, United States
    Duration: 22 May 202227 May 2022

    Publication series

    NameProceedings - International Conference on Software Engineering
    ISSN (Print)0270-5257

    Conference

    Conference44th ACM/IEEE International Conference on Software Engineering: Companion, ICSE-Companion 2022
    Country/TerritoryUnited States
    CityPittsburgh
    Period22/05/2227/05/22

    Keywords

    • Software Refactoring
    • Software Testing

    Fingerprint

    Dive into the research topics of 'JMocker: Refactoring Test-Production Inheritance by Mockito'. Together they form a unique fingerprint.

    Cite this