testing-anti-patterns

Identify and rectify common testing anti-patterns in test suites.

3|2|Updated Dec 28, 2025
One-click install
npx skills add https://github.com/Crumbgrabber/llm_system_template_agents_skills_patterns_tools_prompts --skill testing-anti-patterns-crumbgrabber
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/Crumbgrabber/llm_system_template_agents_skills_patterns_tools_prompts/tree/main/skills/testing-anti-patterns
Command: npx skills add https://github.com/Crumbgrabber/llm_system_template_agents_skills_patterns_tools_prompts --skill testing-anti-patterns-crumbgrabber

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers avoid common testing anti-patterns that lead to brittle, unreliable, and misleading tests. It ensures tests verify actual behavior rather than mock implementations.

Core Features & Use Cases

  • Identify and Rectify: Learn to spot and fix issues like testing mock behavior, polluting production code with test-only methods, and unnecessary mocking.
  • Promote Robust Testing: Encourages practices that lead to more maintainable and trustworthy test suites.
  • Use Case: A developer is writing tests for a new feature and finds themselves mocking a complex dependency. This Skill guides them to question the mock, understand the real behavior needed, and potentially refactor the test or the code for better isolation and clarity.

Quick Start

Review the testing anti-patterns and their fixes to improve your current test suite.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
What are common unit testing anti-patterns and how do they affect code quality?

Common unit testing anti-patterns include testing mock behavior instead of actual behavior, polluting production code with test-only methods, and mocking without understanding dependencies, which leads to brittle, unreliable, and misleading tests.

How do I stop writing unit tests that just verify mock behavior?

To stop verifying mock behavior, you must question the mock, understand the real dependency behavior needed, and refactor the test or production code to achieve better isolation and verify actual outcomes rather than mock implementations.

Why does my test suite break when I refactor production code?

Your test suite breaks during refactoring because of testing anti-patterns like excessive mocking and testing implementation details, which create brittle tests that fail to verify actual behavior and maintainability.

When should I avoid using mocks in my TDD workflow?

You should avoid using mocks when you lack an adequate understanding of the dependency, as unnecessary mocking without comprehending real behavior leads to misleading tests that fail to verify actual software behavior.

How do I remove test-only methods from my production code?

To remove test-only methods from production code, you must refactor the implementation to eliminate test-specific logic, promoting TDD principles that ensure tests verify actual behavior without polluting the production environment.

What is the best way to refactor tests for better isolation and clarity?

The best way to refactor tests for better isolation is to evaluate complex dependencies, understand the real behavior required, and apply TDD principles to ensure tests remain maintainable and trustworthy without unnecessary mocking.