Testing Anti-Patterns Guide
CommunityAvoid common testing pitfalls and keep tests honest.
System Documentation
What problem does it solve?
This document identifies three foundational rules for effective testing and outlines five major anti-patterns to avoid.
Core Principles
The core guidance emphasizes that "Tests must verify real behavior, not mock behavior." Mocks are a means to isolate, not the thing being tested.
The document identifies five major anti-patterns:
- Testing Mock Behavior: Asserting that mocks exist rather than verifying real component output represents a fundamental test failure.
- Test-Only Methods: Adding methods like destroy() solely for test cleanup pollutes production code. Instead, place cleanup logic in dedicated test utilities.
- Mocking Without Understanding: Over-mocking to "be safe" often breaks critical test logic by replacing methods whose side effects the test depends upon. Understanding dependency chains before mocking is essential.
- Incomplete Mocks: Partial mock objects create false confidence—they pass tests while failing in real integration when code accesses unmocked fields.
- Integration Tests as Afterthought: TDD prevents this by writing tests first, which naturally surfaces what actually needs mocking versus what should remain real.
Prevention Strategy
Test-Driven Development inherently prevents these anti-patterns by forcing developers to observe tests fail against real implementations before adding mocks. This process reveals whether mocks are genuinely needed or whether complex mock setups suggest reconsidering the testing approach entirely.
Quick Start
Review a failing test suite to identify mocks and anti-patterns, remove test-only methods, and ensure tests verify real behavior rather than mocks.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: Testing Anti-Patterns Guide Download link: https://github.com/mikeyobrien/ghclip/archive/main.zip#testing-anti-patterns-guide Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.