Stub: An object that simulates a specific return value without verifying calls; you should use this when you just need fake data for your test.
Mock: An object that simulates a return and also verifies if it was called; you should use this when you want to test behavior and interactions.
Spy: An object that runs real code but allows you to observe calls; you should use this when you want to monitor interactions without changing behavior.
Understanding when to use a stub, mock, or spy might sound like a small technical detail — but trust me, it’s one of those things that truly elevates your test writing game.