$Testing Anti-Patterns
Identify and avoid the five major testing anti-patterns that undermine code quality. Learn why mocking without understanding breaks tests, how test-only methods pollute production code, and the importance of testing actual behavior rather than mock behavior.
Views:
Rating:
Tags
#testing#anti-patterns#mocks#best-practices#code-quality
Author
Jesse Vincent
@obra
Version
1.0.0
Category
DevelopmentSource
repo: obra/superpowers
path: skills/obra/testing-anti-patterns
Install
clawd add obra/testing-anti-patternsTesting Anti-Patterns
This skill teaches how to identify and avoid the five major anti-patterns that undermine effective testing practices. The core principle: "Test what the code does, not what the mocks do."
The Three Iron Laws
- Never verify mock behavior
- Never add test-only methods to production classes
- Never mock without understanding dependencies
Five Major Anti-Patterns
- Testing Mock Behavior - Verifying mocks exist rather than actual functionality
- Test-Only Methods in Production - Adding cleanup methods that only tests call
- Mocking Without Understanding - Over-mocking that eliminates necessary side effects
- Incomplete Mocks - Partial mocks that hide structural assumptions
- Integration Tests as Afterthought - Testing after implementation instead of before
Prevention Strategy
Writing tests first through TDD forces examination of actual behavior before mocking, catching these anti-patterns early. This skill works best in combination with Test-Driven Development practices.