Mock Objects in Software Testing: An Analysis of Usage in Open-Source Projects


연구 분야: Verification



학회: SBQS '23: Proceedings of the XXII Brazilian Symposium on Software Quality


초록

Dependencies in software are essential for efficiently structuring and modularizing the code, enabling software components to perform specific tasks, interact, and reuse functionalities. Furthermore, many applications also rely on external components, such as APIs and external services, which can difficult the creation of a testing environment. To overcome these challenges, developers can use mocks to simulate these dependencies, which becomes particularly useful when dealing with slow or hard-to-create dependencies, such as those requiring network access. Despite the use of mocks in software testing, there are few academic studies to understand the use of this technique. The main objective of this paper is to understand how mocks are used in automated tests in open-source projects, in addition to quantifying the use of support tools and assessing their impact on test creation. We discovered that Mockito, PHPUnit, Jest, and Mock tools are widely employed for Java, PHP, JavaScript, and Python programs, respectively. We also observed that the presence of mocks is consistent and follows the number of test files in each project. We noted that the external dependencies to the project were the most frequently simulated. However, we found no significant correlation between the number of mocks in the project and code coverage.


Author Profile
Raphael de Almeida

Universidade Federal Fluminense Brazil

Brazil
Author Profile
Rômulo Martins Da Silva

Universidade Federal Fluminense Brazil

Brazil
Author Profile
Lucas Serrano

Universidade Federal Fluminense Brazil

Brazil

📄 논문 정보

발행 연도 2023년
인용수 2
출판 국가 Brazil
사이트 ACM
좋아요 수 0

연관 논문 목록 (341건)