testing-anti-patterns

Detects/prevents testing anti-patterns in codebases via gate checks and Iron Laws for Testing.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/d-oit/do-novelist-ai --skill testing-anti-patterns-d-oit
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/d-oit/do-novelist-ai/tree/main/.claude/skills/testing-anti-patterns
Command: npx skills add https://github.com/d-oit/do-novelist-ai --skill testing-anti-patterns-d-oit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents testing anti-patterns like testing mock behavior, adding test-only methods to production code, and mocking without understanding dependencies.

Core Features & Use Cases

  • Iron Laws for Testing: NEVER test mock behavior, NEVER add test-only methods to production, NEVER mock without understanding dependencies.
  • Anti-Pattern Examples: Real-world bad/good examples with concrete fixes.
  • Gate Functions: Guidance prompts to decide when to mock and how to structure tests.

Quick Start

Refactor a test that mocks production behavior to verify real behavior instead.

Frequently Asked Questions about testing-anti-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid testing mock behavior instead of real behavior?

Testing mock behavior means validating how mocks are called rather than verifying actual system functionality. Instead, structure tests to assert real behavior: call production code with test inputs, verify actual outputs or side effects, and use mocks only to isolate external dependencies you don't control. This ensures tests catch real failures.

Why shouldn't I add test-only methods to production code?

Test-only methods bloat production with code that never runs in real use and create false test confidence. Instead, refactor production code to expose the behavior through its normal API, or test through public interfaces. This keeps production lean and tests honest about what actually executes.

When should I mock a dependency, and when shouldn't I?

Mock only external dependencies you don't own or can't control (APIs, databases, file systems). Before mocking, understand what the dependency does and why it matters. For code you own, prefer real objects or fakes. Mocking without understanding dependencies leads to tests that pass while production fails.

What's the difference between testing mock calls and testing real outcomes?

Testing mock calls verifies that code interacted with a mock correctly but says nothing about whether the real behavior works. Testing real outcomes asserts that given certain inputs, the code produces correct results or side effects. Real-outcome tests catch integration bugs; mock-call tests catch only broken mocks.

How do I refactor a test that over-mocks to verify real behavior?

Identify which mocks mask real logic rather than isolate unavoidable external calls. Replace unnecessary mocks with real implementations or test doubles that behave like the real thing. Keep only mocks for true external dependencies. Run the refactored test against production code to confirm it catches real failures.

What are common signs my test suite relies too heavily on mocks?

Signs include: tests pass but production breaks, many assertions on mock interactions rather than outputs, tests validate mock setup instead of behavior, and test-only production code. Apply the iron laws: never test mock behavior, never add test-only code, never mock without understanding. Refactor toward real-behavior validation.