Glossary

Mocking (Test Doubles)

A mock is a fake object that simulates the behaviour of a real dependency in tests. Instead of a real email service, database, or external API — a mock returns preset data and verifies that the code behaves correctly.

Types of test doubles

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.