Skill: Craft Test
"Test behavior, not implementation."
The Standard
- One Behavior Per Test: A test verifies one thing. If the name has "and", split it.
- Arrange-Act-Assert: Setup, execute, verify. No interleaving.
- Test the API: Public interface only. Implementation changes shouldn't break tests.
The Anti-Patterns
| Don't | Do | Why |
|---|---|---|
| Test private methods | Test through public API | Coupling |
| Assert implementation | Assert behavior | Fragility |
| Multiple acts per test | One act, one test | Clarity |
| Dense setup chains | Two-line setup | Readability |
| Vague names | Complete sentences | Documentation |
Real-World Examples
See examples.md.