|
| 1 | += Test Double (Meszaros) |
| 2 | +:categories: testing-quality |
| 3 | +:roles: software-developer, qa-engineer, educator |
| 4 | +:proponents: Gerard Meszaros |
| 5 | +:related: tdd-london-school, tdd-chicago-school, property-based-testing |
| 6 | +:tags: test-double, mock, stub, spy, fake, dummy, xunit, testing, isolation |
| 7 | + |
| 8 | +[%collapsible] |
| 9 | +==== |
| 10 | +Full Name:: Test Double taxonomy according to Gerard Meszaros |
| 11 | + |
| 12 | +Also known as:: xUnit Test Patterns test double taxonomy |
| 13 | + |
| 14 | +[discrete] |
| 15 | +== *Core Concepts*: |
| 16 | + |
| 17 | +Dummy:: Object passed to fill a parameter list but never actually used |
| 18 | + |
| 19 | +Stub:: Provides canned responses to calls made during a test; no verification of interactions |
| 20 | + |
| 21 | +Spy:: Records calls made to it for later assertion; a stub that also captures interaction data |
| 22 | + |
| 23 | +Mock:: Pre-programmed with expectations; verifies that specific interactions occurred (interaction-based verification) |
| 24 | + |
| 25 | +Fake:: Working simplified implementation with shortcuts unsuitable for production (e.g., in-memory database, in-memory repository) |
| 26 | + |
| 27 | +Test Double:: Umbrella term for any object substituted for a real dependency during testing |
| 28 | + |
| 29 | +Vocabulary precision:: Distinguishing what a double IS (taxonomy) from when to use it (TDD school philosophy) |
| 30 | + |
| 31 | + |
| 32 | +Key Proponent:: Gerard Meszaros ("xUnit Test Patterns: Refactoring Test Code", 2007) |
| 33 | + |
| 34 | +[discrete] |
| 35 | +== *When to Use*: |
| 36 | + |
| 37 | +* Communicating precisely about test isolation strategies |
| 38 | +* Choosing the right type of double for a given testing scenario |
| 39 | +* Avoiding vocabulary collisions (e.g., calling a Stub a "mock" triggers wrong reasoning) |
| 40 | +* Teaching or reviewing test code with shared terminology |
| 41 | + |
| 42 | +[discrete] |
| 43 | +== *Related Anchors*: |
| 44 | + |
| 45 | +* <<tdd-london-school,TDD, London School>> - Philosophy of when to use doubles heavily (interaction-based) |
| 46 | +* <<tdd-chicago-school,TDD, Chicago School>> - Philosophy of minimal doubling (state-based) |
| 47 | +==== |
0 commit comments