Test doubles are objects that stand in for real dependencies in tests — including mocks, stubs, spies, fakes, and dummies. They isolate the code under test from its dependencies (databases, APIs, services), enabling fast, focused, controlled unit tests.
Why test doubles
To test a unit in ISOLATION, replace its real dependencies (DB, API, services) with
TEST DOUBLES (fake stand-ins):
→ isolate the unit (test ONLY it, not its dependencies)
→ FAST (no real DB/network); CONTROLLED (set up exact scenarios, including errors);
DETERMINISTIC (no external flakiness)
