Introduction
Mocks and stubs help test parts of software by pretending to be other parts. They make testing easier and faster.
When you want to test a feature but the real service is not ready or slow.
When you want to check how your code reacts to specific responses from another service.
When you want to isolate your test from external systems to avoid failures caused by them.
When you want to simulate error conditions that are hard to create with real services.