overmocking
Overmocking is a term used in software testing to describe a situation where tests rely excessively on mock objects, stubs, and fakes to the point that they no longer reflect the real behavior of the system. It often involves replacing internal collaborators or implementation details with mocks and focusing on verifying interactions rather than validating observable outcomes.
Causes of overmocking include a desire to isolate unit tests from any dependencies, assumptions that mocks
The consequences are often counterproductive. Tests become brittle, failing when implementation detail changes even if user-facing
Signs of overmocking include heavy use of interaction testing (verifying call order and specific method invocations),
Best practices to avoid overmocking emphasize mocking only external dependencies and stable interfaces, testing observable behavior