over-mocking
Replacing so many collaborators with mocks that tests only check the script the test writer invented, not real behaviour.
In more detail
The suite goes green while the system is broken, because each mock returns exactly what its test told it to. Prefer observable results over rehearsed call sequences, and let a fake or a real dependency check the contract.
Related terms
- mock — A test double that stands in for a real dependency and checks that the code under test calls it in the expected way.
- false positive — A check result that claims something is true when it is not, such as a test passing on broken code or a tool flagging correct code.
- fake — A test double that is a small but working implementation of a dependency, such as an in-memory database standing in for a real one.
- API contract — The written promise an API makes about its operations, inputs, outputs and errors, which callers rely on while the code behind it changes.
Taught in
- The Test Pyramid And Where It Is Wrong — Automated Testing, TDD & Quality Engineering
- Why Over-Mocking Breeds False Positives — Automated Testing, TDD & Quality Engineering