Skip to content
Preptima
mediumConceptScenarioMidSeniorStaff

Your suite mocks the database, every test passes, and the release still broke. What should you have tested instead?

5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

A mock encodes your belief about the collaborator, so asserting against it proves the code matches your belief rather than reality. Use autospec so signatures are checked, and put a small number of tests against the real engine at the boundary the mock replaced.

Was this answer helpful?

Likely follow-ups

  • What kinds of bug does a SQLite substitute for PostgreSQL hide rather than catch?
  • How would you keep a hand-written fake honest about the real implementation's behaviour?
  • Where do you draw the line between a unit test with doubles and an integration test?
  • How would you make a real-database test suite fast enough that people still run it locally?

Related questions

Further reading

Related Topics