Use when writing or changing tests, adding mocks - prevents testing mock behavior, production pollution with test-only methods, and mocking without understanding dependencies
View on GitHubwithzombies/hyperpowers
withzombies-hyper
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/withzombies/hyperpowers/blob/main/skills/testing-anti-patterns/SKILL.md -a claude-code --skill testing-anti-patternsInstallation paths:
.claude/skills/testing-anti-patterns/<skill_overview>
Tests must verify real behavior, not mock behavior; mocks are tools to isolate, not things to test.
</skill_overview>
<rigidity_level>
LOW FREEDOM - The 3 Iron Laws are absolute (never test mocks, never add test-only methods, never mock without understanding). Apply gate functions strictly.
</rigidity_level>
<quick_reference>
## The 3 Iron Laws
1. **NEVER test mock behavior** → Test real component behavior
2. **NEVER add test-only methods to production** → Use test utilities instead
3. **NEVER mock without understanding** → Know dependencies before mocking
## Gate Functions (Use Before Action)
**Before asserting on any mock:**
- Ask: "Am I testing real behavior or mock existence?"
- If mock existence → STOP, delete assertion
**Before adding method to production:**
- Ask: "Is this only used by tests?"
- If yes → STOP, put in test utilities
**Before mocking:**
- Ask: "What side effects does real method have?"
- Ask: "Does test depend on those side effects?"
- If depends → Mock lower level, not this method
</quick_reference>
<when_to_use>
- Writing new tests
- Adding mocks to tests
- Tempted to add method only tests will use
- Test failing and considering mocking something
- Unsure whether to mock a dependency
- Test setup becoming complex with mocks
**Critical moment:** Before you add a mock or test-only method, use this skill's gate functions.
</when_to_use>
<the_iron_laws>
## Law 1: Never Test Mock Behavior
**Anti-pattern:**
```rust
// ❌ BAD: Testing that mock exists
#[test]
fn test_processes_request() {
let mock_service = MockApiService::new();
let handler = RequestHandler::new(Box::new(mock_service));
// Testing mock existence, not behavior
assert!(handler.service().is_mock());
}
```
**Why wrong:** Verifies mock works, not that code works.
**Fix:**
```rust
// ✅ GOOD: Test real behavior
#[test]
fn test_processes_request() {
let service = TestApiService::new(); // Real implementation or full fake
let handler =