Test doubles taxonomy
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
name the kinds of test double and pick the right one.
Planned topics
- A test double is any stand-in for a real collaborator during a test.
- A stub returns canned answers. A mock also records calls so you can verify them.
- A spy wraps a real object and records calls. A fake is a simple working version, such as an in-memory repository.
- Prefer a fake or the real object when it is cheap; use a mock when you must check an interaction or simulate failure.
- The goal is to isolate the code under test, not to remove every dependency.
Draft outline details
Demonstration
a table: type / what it does / Shop example (stub: exchange rates; mock: email sender; spy: real calculator; fake: in-memory OrderRepository).
Check your understanding
Which double is a working in-memory version of a repository?
Show answer
A fake.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.