testing-anti-patterns

Educate developers on testing anti-patterns and solutions for test quality.

Updated Jan 9, 2026
One-click install
npx skills add https://github.com/maplin-co/ai-course --skill testing-anti-patterns-maplin-co
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/maplin-co/ai-course/tree/main/.opencode/skill/testing-anti-patterns
Command: npx skills add https://github.com/maplin-co/ai-course --skill testing-anti-patterns-maplin-co

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers avoid common testing anti-patterns that lead to brittle, misleading, or unmaintainable tests, ensuring tests verify real behavior and don't pollute production code.

Core Features & Use Cases

  • Identify and Rectify: Learn to spot and fix issues like testing mock behavior, adding test-only methods to production code, and mocking without understanding dependencies.
  • Improve Test Quality: Write tests that are more robust, reliable, and provide genuine confidence in the codebase.
  • Use Case: A developer is writing tests for a new feature and finds themselves tempted to add a _cleanupForTest() method to a production class. This Skill guides them to use test utilities instead, keeping production code clean.

Quick Start

Use the testing-anti-patterns skill to understand why testing mock behavior is a problem.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
What is a testing anti-pattern and how does it affect unit testing?

A testing anti-pattern is a flawed practice like testing mock behavior instead of real code, which creates brittle and misleading unit tests that fail to verify actual software behavior.

How do I stop polluting production code with test-only methods?

To stop polluting production code, avoid adding test-only methods like _cleanupForTest() to production classes; instead, use dedicated test utilities and refactor dependencies to keep the main codebase clean.

Why does mocking dependencies without understanding lead to bad tests?

Mocking dependencies without understanding them leads to unreliable tests because you risk verifying the mock's internal behavior rather than the actual business logic, resulting in false confidence in your codebase.

How does TDD prevent common unit testing anti-patterns?

TDD prevents common unit testing anti-patterns by driving design through tests first, ensuring you mock dependencies properly and write maintainable tests that verify real behavior rather than implementation details.

What is the best way to refactor brittle tests that rely on mock behavior?

The best way to refactor brittle tests is to stop verifying mock interactions and instead assert observable outcomes, removing test-only production methods and ensuring tests validate genuine business requirements.

When should I not use mocking in my unit tests?

You should not use mocking when you lack a clear understanding of the dependency's behavior, as mocking without comprehension creates misleading tests that validate mock interactions instead of actual application logic.