Types of test doubles
- Stub — returns preset values. No call verification
- Mock — additionally verifies that certain methods were (or were not) called
- Spy — records calls but delegates to the real implementation
- Fake — a simplified real implementation (in-memory repository)
- Dummy — a placeholder object passed but never used
When not to mock
Mock external dependencies (email, S3, payment systems), not your own code. If you find yourself mocking your own classes, that is a signal the architecture needs refactoring.