testing-anti-patterns

Detect testing anti-patterns in unit and integration test suites.

155|25|Updated Apr 27, 2025
One-click install
npx skills add https://github.com/sammcj/agentic-coding --skill testing-anti-patterns-sammcj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/sammcj/agentic-coding/tree/main/Claude/skills/testing-anti-patterns
Command: npx skills add https://github.com/sammcj/agentic-coding --skill testing-anti-patterns-sammcj

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents common testing anti-patterns that lead to fragile tests, false confidence, and production code pollution.

Core Features & Use Cases

  • Anti-Pattern Detection: Identifies and corrects testing of mock behavior instead of real component behavior.
  • Code Quality Enforcement: Prevents test-only methods from contaminating production classes.
  • Use Case: When your team is writing unit tests and tempted to add complex mocks or test-specific methods, use this Skill to ensure tests verify actual functionality rather than mock implementations.

Quick Start

Use the testing-anti-patterns skill to review this test code and identify any violations of the iron laws of testing.

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 in unit tests?

Testing mock behavior creates false confidence without verifying actual functionality. Instead, test real component interactions and dependencies; mocks should stand in for external services, not replace the logic you're validating. This Skill identifies when tests verify mock setup rather than production code behavior.

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

Test-only methods pollute production classes, increase maintenance burden, and blur the line between testable design and test infrastructure. Production code should be designed for real use; if you need special test methods, redesign dependencies and interfaces instead.

What's the difference between mocking correctly and creating brittle tests?

Brittle tests mock without understanding their dependencies, leading to tests that pass when production fails. Correct mocking requires understanding what external behavior to isolate and what internal behavior to verify, preventing false confidence in test suites.

How do I review test code for common anti-patterns?

Review for three core violations: testing mock behavior instead of real behavior, adding test-specific methods to production classes, and mocking without understanding dependencies. This Skill enforces gate checks during test development and review to catch these patterns early.

When should I use mocks in unit tests versus integration tests?

Use mocks in unit tests to isolate the code under test from external dependencies; use integration tests to verify real component interaction. In both cases, never test the mock's behavior itself—always verify that your production code correctly uses the mocked interface.