Mock objects: a case study in industry - Ibarra, Camilo Hernán Villota; Faria, Daniel Lippi Castro De; Endo, André Takeshi; Beder, Delano Medeiros; Vincenzi, Auri Marcelo Rizzo (Anais do Simpósio Brasileiro de Sistemas de Informação (SBSI); 2023: Anais do XIX Simpósio Brasileiro de Sistemas de Informação, 2023)
Context: Mock objects are commonly used in unit tests to isolate a class from its dependencies by substituting a dependency class instead of the original. Problem: However, in addition to the use of mock objects in the vast majority of OO applications, there are some discrepancies in their use. Solution: This work aims to present a case study of an industry application regarding the use of mock objects. The application in question is part of a private flight management system. IS Theory: We conceived this work based on the General Systems Theory, specifically to evaluate a microservice-based system's use of testing doubles during testing automation. Method: In the analyzed application, mock object implementations are highly related to the system design. For example, the number of dependencies in a production class is directly related to the number of mocks in the respective test class. As a consequence, poor design choices are harmful to intrinsic quality factors such as the maintainability of the application tests. Our study uses metrics to analyze this practice. The research will consider factors of this system, aiming mainly to contribute to the improvement of test doubles by the test team. Summary of Results: Application of simulated objects in a similar system indicates that developers are making immature use of the technique, possibly due to system design problems. This study concludes that theory and practice are misaligned. Contributions and Impact in the IS area: The main contribution is to indicate points to improving software testing practice by using mocks correctly.