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
- You own the API test suite for a service from scratch. How do you structure it, and what do you mock?hardAlso on mocking8 min
- How do you test a Node service, and what do you refuse to mock?mediumAlso on mocking6 min
- How do you test a service that calls a third-party API, without calling it?mediumAlso on test-doubles4 min
- Your test still reaches the network even though you patched the client. Talk me through fixture scope, parametrisation, and where a patch has to point.mediumAlso on mocking4 min