testing-anti-patterns

Detect testing anti-patterns like mock behavior and test-only production methods.

Updated Oct 28, 2025
One-click install
npx skills add https://github.com/AlabamaMike/copilot-agents --skill testing-anti-patterns-alabamamike
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/AlabamaMike/copilot-agents/tree/main/.codex/superpowers/skills/testing-anti-patterns
Command: npx skills add https://github.com/AlabamaMike/copilot-agents --skill testing-anti-patterns-alabamamike

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Poor testing practices, such as testing mock behavior, polluting production code with test-only methods, or incomplete mocks, lead to brittle, unreliable tests that provide false confidence. This skill identifies and helps avoid these common anti-patterns, ensuring your tests verify real behavior and contribute to robust code.

Core Features & Use Cases

  • Mock Behavior Prevention: Guides against testing mocks instead of actual component behavior.
  • Production Code Purity: Prevents adding test-only methods to production classes.
  • Dependency Understanding: Ensures mocks are used judiciously and with full understanding of dependencies.
  • Use Case: When reviewing or writing new tests, use this skill to identify and correct anti-patterns like incomplete mocks or testing mock internals, ensuring your tests are truly effective.

Quick Start

Use the testing-anti-patterns skill to review the 'payment-gateway.test.ts' file for common testing mistakes.

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 component behavior?

Testing mock behavior instead of real component behavior creates false confidence in your tests. This anti-pattern occurs when assertions verify mock internals rather than actual component outputs. Write tests that exercise real dependencies and logic, using mocks only to isolate external concerns like API calls or databases, ensuring your tests validate genuine behavior.

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

Test-only methods in production code pollute your codebase and hide design issues. They couple production logic to testing needs and create maintenance burden. Instead, refactor code to be testable through its public API, use dependency injection to enable testing, or create separate test utilities outside production classes.

When should I use mocks in unit and integration tests?

Use mocks to isolate the code under test from external dependencies like databases, APIs, or third-party services. Understand each dependency before mocking it—incomplete or incorrect mocks lead to tests that pass but code that fails in production. Mock only what's necessary; test real behavior of core logic and integration points.

How do I write effective tests that catch real bugs?

Effective tests verify actual component behavior, not mock internals. Structure tests to exercise real logic paths, use complete mocks that accurately represent dependencies, and avoid test-only production code. Review tests during code review to catch anti-patterns like incomplete mocks or assertions on mock state rather than outcomes.

What's the difference between testing implementation details and testing behavior?

Testing implementation details means asserting on mock calls or internal state; testing behavior means verifying outputs and side effects. Behavior-focused tests remain valid when refactoring, while implementation-focused tests break unnecessarily. Focus assertions on what the code produces, not how it achieves it.