Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
ProgrammingSeniorOccasionalRisk analysis

How can over-mocking make a test suite unreliable even when it passes?

Answer

Over-mocked tests can reproduce the implementation rather than validate observable behavior. They pass against invented dependency behavior, fail during harmless refactoring, and miss incompatible schemas, defaults, timing and failure modes. Review whether each interaction matters to a consumer, prefer state or outcome assertions, and retain contract and integration tests at real boundaries.

Strong answer includes

  • identifies false confidence and refactoring coupling
  • mentions behavioral drift between doubles and real dependencies
  • proposes outcome assertions and boundary checks

Practical example

A team mocks an inventory client to always return inStock: true; six months later the real API starts returning null for discontinued items, and the mocked unit suite stays green while checkout crashes in production because no contract test ever exercised that field.

#test-doubles#maintainability#unit-testing#sdet

Sources

Use test doubles in AndroidGoogle · Definitions, selection and limitations of dummies, stubs, spies, mocks and fakesPlaywright best practicesMicrosoft · Reliable modern browser automation