I test double sono oggetti che sostituiscono le dipendenze reali nei test — inclusi mock, stub, spy, fake e dummy. Isolano il codice sotto test dalle sue dipendenze (database, API, servizi), consentendo unit test veloci, focalizzati e controllati.
Perché è importante
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)
