skills/eng-testing-anti-patterns/SKILL.md
Use when writing or modifying tests, adding mocks, or considering test-only hooks—prevents common mistakes like testing mocks, polluting production with test helpers, and mocking without understanding dependencies.
npx skillsauth add tjboudreaux/cc-plugin-engineering-excellence eng-testing-anti-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Tests must validate real behavior, not mock behavior. Mocks are isolation tools; they are never the subject under test. Follow these guardrails whenever you touch tests or mocks.
Iron Laws
1. NEVER test mock behavior
2. NEVER add test-only methods to production classes
3. NEVER mock without understanding dependencies
4. NEVER ship incomplete mocks
5. NEVER treat integration tests as an afterthought
getByTestId('sidebar-mock') exists after mocking <Sidebar/>.Gate: Before asserting on a mock, ask “Am I testing actual behavior or just the mock?” If it’s the mock, delete the assertion or unmock.
Session.destroy() only used in tests.Gate: Before adding a method, ask “Is this only for tests?” and “Does this class own the lifecycle?” If “yes” or “no” respectively, stop.
Gate: Before mocking, answer:
metadata.requestId.Gate: Examine real API/docs, include every field consumers might touch. If uncertain, copy the full structure.
If mock setup eclipses test logic, reconsider. Ask “Do we need a mock here?” Integration tests with real components may be simpler.
Following TDD ensures tests verify real behavior (fail first), prevents test-only prod code, and reveals when mocks are unnecessary.
| Anti-Pattern | Fix | |--------------|-----| | Assert on mock | Test real behavior or unmock | | Test-only methods | Move to test utilities | | Blind mocking | Understand dependencies first | | Partial mocks | Match real API schema | | No tests | TDD cycle |
*-mockBottom line: Mocks isolate but are never the unit under test. Test real behavior, and let TDD guide your workflow.
tools
Systematic debugging playbook for tracing failures backward through the call chain, adding instrumentation, and fixing bugs at their origin.
testing
Startup protocol for every task—discover applicable skills, run them, announce usage, and follow required workflows (brainstorming, TodoWrite checklists, etc.).
testing
Mandatory checklist before claiming work is complete—run the evidence-producing command, inspect output, and only then state a result.
testing
Anchor every engineering decision in user value, measurable outcomes, accessibility, and cross-platform experience coherence.