principles
Answers test design questions from authoritative TDD sources (Beck, Khorikov), producing WHY reasoning to improve test design decisions. Use when: 'should I mock this', 'four pillars of a good test', 'red green refactor', 'classical vs london school', 'test doubles', 'testing anti-patterns', 'resistance to refactoring', 'code coverage', 'observable behavior', 'humble object', 'integration test', 'test pyramid', 'output vs state vs communication test', 'property-based testing', 'characterization test', 'legacy code'. Not for HOW to run tests in the project (use the project's own test tooling and workflow for that).
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 30
- Forks
- 7
01 前言 Front Matter
- metadata
- { "summary": "Answer test design questions from authoritative TDD sources", "workflow-stage": "test" }
- description
- Answers test design questions from authoritative TDD sources (Beck, Khorikov), producing WHY reasoning to improve test design decisions. Use when: 'should I mock this', 'four pillars of a good test', 'red green refactor', 'classical vs london school', 'test doubles', 'testing anti-patterns', 'resistance to refactoring', 'code coverage', 'observable behavior', 'humble object', 'integration test', 'test pyramid', 'output vs state vs communication test', 'property-based testing', 'characterization test', 'legacy code'. Not for HOW to run tests in the project (use the project's own test tooling and workflow for that).
- argument-hint
- [question or concept]
- user-invocable
- true
- disable-model-invocation
- false
02 资源文件 16
- 参考文档reference/anti-patterns-khorikov.md10.2 KB
- 参考文档reference/characterization-testing.md5.0 KB
- 参考文档reference/classical-vs-london-khorikov.md8.3 KB
- 参考文档reference/code-coverage-khorikov.md7.9 KB
- 参考文档reference/four-pillars-khorikov.md6.9 KB
- 参考文档reference/integration-testing-khorikov.md19.8 KB
- 参考文档reference/methodology-beck.md8.7 KB
- 参考文档reference/money-example-beck.md7.2 KB
- 参考文档reference/observable-behavior-khorikov.md10.1 KB
- 参考文档reference/property-based-testing.md8.9 KB
- 参考文档reference/refactoring-under-test.md6.3 KB
- 参考文档reference/test-design.md13.0 KB
- 参考文档reference/test-doubles.md8.3 KB
- 参考文档reference/testable-architecture-khorikov.md13.9 KB
- 参考文档reference/testing-styles-khorikov.md15.9 KB
- 参考文档reference/xunit-example-beck.md5.7 KB
03 SKILL.md 正文
TDD Knowledge Base
The Beck and Khorikov files are distilled from cover-to-cover reading of those books. Two files are not: property-based-testing.md and characterization-testing.md are built from web sources, listed separately under Sources. Reference files in reference/ have author-attributed sections with synthesis where authors overlap.
Routing Table
| Query about... | Load |
|---|---|
| TDD cycle, red-green-refactor, when/why TDD, step size, courage, stress, fear | methodology-beck.md |
| What makes a good test, what to test, 3A, Fixture, test naming, parameterized tests | test-design.md |
| Mocks, stubs, fakes, mock/stub taxonomy, CQS connection, 5 mocking best practices | test-doubles.md |
| Refactoring safely, design patterns in TDD, Humble Object, four types of code | refactoring-under-test.md |
| Four Pillars of a good test, brittle tests, false positives, resistance to refactoring | four-pillars-khorikov.md |
| Code coverage metrics, branch vs statement, goal of unit testing | code-coverage-khorikov.md |
| Classical vs London school, dependency taxonomy, shared/private/out-of-process | classical-vs-london-khorikov.md |
| Observable behavior, implementation details, hexagonal architecture, encapsulation | observable-behavior-khorikov.md |
| Output/state/communication styles, functional architecture, functional core | testing-styles-khorikov.md |
| Four types of code 2x2, Humble Object, CRM refactoring, CanExecute/Execute, domain events, preconditions | testable-architecture-khorikov.md |
| Integration tests, managed vs unmanaged deps, Test Pyramid, database testing, logging, interfaces, reads vs writes | integration-testing-khorikov.md |
| Anti-patterns: private methods, exposing state, domain knowledge, code pollution, DateTime.Now, time | anti-patterns-khorikov.md |
| Beck's Money example, Value Object, Expression metaphor, Factory Method | money-example-beck.md |
| Beck's xUnit example, bootstrap, Template Method, Composite, Collecting Parameter | xunit-example-beck.md |
| Property-based testing: properties as specification, shrinking, property patterns, properties beside example tests, agent-written properties | property-based-testing.md (web-sourced) |
| Legacy code, characterization tests, golden master, approval and snapshot tests, sabotage check, pins prove sameness not correctness | characterization-testing.md (web-sourced) |
Load the most relevant file first. Load a second only if the first doesn't fully answer.
Quick decision guide (no file load needed):
- "Should I write a test for this?" → Yes, unless it's third-party code you trust or trivial code (bottom-left quadrant of the 2x2 matrix: low complexity, few collaborators)
- "Should I mock this?" → Only if it's an unmanaged dependency (message bus, SMTP). Use real instances for managed deps (database)
- "Fake It or Obvious Implementation?" → If confident, Obvious. If surprised by red, back off to Fake It
- "Is this test too big?" → If it needs >3 changes to work, write a smaller Child Test first
- "Test before or after?" → Before. Always. "You won't test after"
- "Output, state, or communication test?" → Output-based first. State-based second. Communication-based only for inter-system with visible side effects
- "Is this code testable?" → Check the 2x2 matrix. High complexity + many collaborators = split it (Humble Object)
- "Should I introduce an interface?" → Only for unmanaged deps you need to mock. Concrete classes for managed deps. Never for in-process deps
- "Should I test this precondition?" → Yes if it has domain significance (e.g., non-negative employees). No if it's purely technical (array length check)
- "Should I test this read operation?" → Higher threshold than writes. Writes corrupt data, so always test. Reads: only the most complex/important ones
- "Domain event or direct call?" → Use domain events when the domain model needs to trigger external notifications without depending on out-of-process deps
- "Why is my test brittle?" → It's probably coupled to implementation details. Check: are you asserting on observable behavior or internal structure?
Sources
- Beck: Kent Beck, Test-Driven Development: By Example (2003)
- Khorikov: Vladimir Khorikov, Unit Testing: Principles, Practices, and Patterns (2020)
- Ousterhout (secondary, cross-referenced only): John Ousterhout, A Philosophy of Software Design, cited in one editorial-synthesis section of test-doubles.md
- Mutation-testing literature (secondary, cross-referenced only): the primary sources on mutation testing, cited in one clearly-labeled editorial note in each of code-coverage-khorikov.md and four-pillars-khorikov.md, where a claim of Khorikov's has a measurable partial exception he does not cover. Both notes are marked as outside his text and leave his claim standing. The material itself is owned by
/mutation-testing:principleswhen themutation-testingplugin is enabled; without it, each note carries its own one-line fallback.
Web-sourced references (not book readings)
These two files were built from web pages, papers' abstract and HTML pages, and tool docs read on 2026-10-06, not from reading a book. Each file lists its sources with read depth and a recheck trigger; this list is rechecked when either file's trigger fires.
- property-based-testing.md: Hypothesis, fast-check and other property tools' docs; Maaz et al. (arXiv 2510.09907, NeurIPS 2025 workshop paper); Vikram et al. (arXiv 2307.04346); PROBE (ACL 2026 Findings). No property-based testing book was read.
- characterization-testing.md: Michael Feathers' 2016 "Characterization Testing" page (his book Working Effectively with Legacy Code was not read); Mark Seemann's 2025 "Empirical characterization testing" post; ApprovalTests, Verify and Jest docs.
Naming convention
{concept}.mdis shared across authors, with attributed sections inside{concept}-{author}.mdis used when only one author covers it substantively
Next
/testing:write
Puts the test-design reasoning into the tests themselves.
Scope boundary
This skill is knowledge (WHY behind testing decisions), not workflow (HOW to run tests). For running, filtering, or scaffolding tests, use your project's own test tooling, conventions, and workflow skills. This skill informs the design decisions those workflows execute.
04 同仓库更多 Skills
track
Backlog reads through the bound tracker: search open and closed items, view one item with its comments and state history. Use when another skill searches or reads tracker items.
reviewer-media
Reviewer media for one pull request: decides whether it needs a narrated walkthrough, builds the storyboard from /review:explain-change's digest, has /explainer-video:produce render it and hands the manifest to /source-control:pull-request media. Use when asked for 'reviewer media', 'a walkthrough video for this PR', 'a produced video of this change', or when pull-request ready or monitor hands a PR over.
route
Model and effort per agent role (orchestrator, worker, verifier, retrieval) for a multi-agent run, resolved through the bundled defaults and the user, team and personal override config layers into fenced JSON with single-agent and fan-out variants and the layer behind each value. Use when asked 'which model for the subagents', 'route the roles' or 'model routing', or before a skill passes a role's model on a spawn.
route
Model and effort per agent role (orchestrator, worker, verifier, retrieval) for a multi-agent run, resolved through the bundled defaults and the user, team and personal override config layers into fenced JSON with single-agent and fan-out variants and the layer behind each value. Use when asked 'which model for the subagents', 'route the roles' or 'model routing', or before a skill passes a role's model on a spawn.
principles
Module-design vocabulary for architecture findings, and the checks built on it. Use when: 'what is a deep module', 'what is a seam', 'deep vs shallow module', 'what is the deletion test', 'leverage and locality', 'module design vocabulary', 'which word do we use for X in architecture findings'. Scanning a codebase for friction is /architecture:improve.
write
Structured five-field bug report (title, steps to reproduce, expected vs actual, justified severity, suggested fix location) from an informal description, read-only. Use when the user names a defect they observed, or asks for one written up ('report a bug', 'file a bug', 'write this up as a bug').