testing-anti-patterns

Review test suites for mock behavior and test-only production methods.

80|17|Updated Oct 27, 2025
One-click install
npx skills add https://github.com/withzombies/hyperpowers --skill testing-anti-patterns-withzombies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/withzombies/hyperpowers/tree/main/skills/testing-anti-patterns
Command: npx skills add https://github.com/withzombies/hyperpowers --skill testing-anti-patterns-withzombies

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents common mistakes in test writing, such as testing mock behavior, polluting production code with test-only methods, or incomplete mocking. It ensures tests are robust, reliable, and truly verify application behavior.

Core Features & Use Cases

  • Identifies Anti-Patterns: Clearly defines and illustrates common testing anti-patterns with code examples (e.g., testing mock existence, test-only methods in production).
  • Provides Fixes: Offers concrete solutions and "gate functions" to prevent these anti-patterns from being introduced.
  • TDD Integration: Emphasizes how strict Test-Driven Development (TDD) naturally prevents most of these issues.
  • Use Case: When reviewing or writing new tests, use this Skill to ensure you're not testing mock behavior, adding test-only methods to production, or creating incomplete mocks that lead to false confidence.

Quick Start

Use the testing-anti-patterns skill to review the current test suite for common pitfalls.

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 application code?

Testing mock behavior verifies the mock exists, not that your application works. Instead, test real behavior by asserting on actual outputs and side effects. Mock only external dependencies, then verify your code's genuine logic through functional assertions.

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

Test-only methods pollute production code, create maintenance debt, and expose internal details that shouldn't exist. Write tests against the public API instead. If you need special test hooks, reconsider your design—TDD naturally prevents this by requiring testable, clean interfaces first.

What are common testing anti-patterns I should watch for?

Common anti-patterns include testing mock existence, incomplete mocks that hide real failures, over-mocking that decouples tests from actual behavior, and test-only production code. This Skill identifies these patterns with concrete examples and provides fixes to ensure tests genuinely verify application behavior.

How does strict Test-Driven Development prevent testing mistakes?

TDD enforces writing tests before code, naturally preventing test-only methods and over-mocking. You design for testability upfront, mock only what's necessary, and avoid testing implementation details. This discipline produces robust, maintainable tests that verify real behavior.

What should I do when reviewing a test suite for mock misuse?

Review tests against the 3 Iron Laws: each test should verify one behavior, use mocks only for external dependencies, and assert on real outcomes—not mock calls. Apply gate functions before asserting on mocks, adding production methods, or completing mocks to catch anti-patterns early.

Can I use mocking frameworks without falling into testing anti-patterns?

Yes, mocking frameworks are valuable when used correctly. Mock only external dependencies (APIs, databases, services), not the code under test. Verify real behavior through assertions on actual outputs, not mock interactions. Understand your dependencies before mocking to avoid false confidence.