testing-patterns
Installation
SKILL.md
Testing Patterns and Anti-Patterns
Overview
Classify test doubles, recognize test smells, apply testing strategies, and avoid TDD anti-patterns. Use when writing tests, reviewing test coverage in a PR, or diagnosing slow/fragile/misleading test suites.
Test Double Taxonomy
Google's preference order: Real > Fake > Stub > Mock
| Double | What it does | Verifies calls? | Has logic? | Use when |
|---|---|---|---|---|
| Dummy | Passed but never used | No | No | Satisfying unused required params |
| Stub | Returns preset values | No | Minimal | Controlling outputs for a specific path |
| Spy | Records calls, delegates to real | Yes (after) | Yes | Verifying call count/args without replacing behavior |
| Mock | Pre-programmed expectations | Yes (during) | No | Strict interaction verification — use sparingly |
| Fake | Simplified working impl | No | Yes | Replacing slow/external systems (in-memory DB, fake API) |