Skip to content

Commit 4555257

Browse files
authored
Merge pull request #142 from Nantero1/add-anchor-test-double
feat: Add Test Double (Meszaros) semantic anchor
2 parents 27a9954 + 77982ca commit 4555257

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

docs/all-anchors.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ include::anchors/property-based-testing.adoc[leveloffset=+2]
159159

160160
include::anchors/tdd-chicago-school.adoc[leveloffset=+2]
161161

162+
include::anchors/test-double-meszaros.adoc[leveloffset=+2]
163+
162164
include::anchors/tdd-london-school.adoc[leveloffset=+2]
163165

164166
include::anchors/testing-pyramid.adoc[leveloffset=+2]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
====

skill/semantic-anchor-translator/references/catalog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Source: https://github.com/LLM-Coding/Semantic-Anchors
1414
- **Proponents:** Kent Beck, Martin Fowler
1515
- **Core:** State-based testing, real objects over mocks, refactoring-focused
1616

17+
### Test Double (Meszaros)
18+
- **Proponents:** Gerard Meszaros
19+
- **Core:** Taxonomy of test substitutes — Dummy (unused), Stub (canned responses), Spy (records calls), Mock (verifies interactions), Fake (simplified implementation)
20+
1721
### Testing Pyramid
1822
- **Core:** Many unit tests, fewer integration tests, fewest E2E tests
1923

0 commit comments

Comments
 (0)