Overview
Coined by Gerard Meszaros, the term 'Test Double' is an analogy to a stunt double in a movie. It is an umbrella term that includes several specific types of simulated objects used in automated testing.
Types of Test Doubles
- Dummy: Passed around but never actually used.
- Stub: Provides canned answers to calls.
- Spy: A stub that also records how it was called.
- Mock: Pre-programmed with expectations about how it should be used.
- Fake: Has a simplified but working implementation.
Purpose
To enable isolation, speed, and reliability in automated tests.