testing-anti-patterns

Identify and correct common testing anti-patterns in software development.

2|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/ucirello/sgai --skill testing-anti-patterns-ucirello
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/ucirello/sgai/tree/main/cmd/sgai/skel/.sgai/skills/testing-anti-patterns
Command: npx skills add https://github.com/ucirello/sgai --skill testing-anti-patterns-ucirello

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write more effective and maintainable tests by identifying and preventing common testing anti-patterns that lead to brittle tests, false confidence, and production pollution.

Core Features & Use Cases

  • Prevent Mock Behavior Testing: Ensures tests verify actual component behavior, not just mock implementations.
  • Avoid Test-Only Production Methods: Keeps production code clean by preventing test-specific methods from being added.
  • Guide Mocking Decisions: Promotes understanding dependencies before mocking, preventing unintended consequences.
  • Ensure Complete Mocks: Encourages mocking complete data structures to avoid silent failures.
  • Promote TDD: Reinforces Test-Driven Development as a preventative measure against anti-patterns.

Quick Start

Review the provided guidance to identify and correct testing anti-patterns in 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 testing anti-patterns that make unit tests brittle?

Common testing anti-patterns include testing mock behavior instead of actual component logic, polluting production code with test-only methods, and mocking dependencies without fully understanding their impact. These pitfalls lead to false confidence and brittle test suites.

How do I stop testing mock behavior and verify actual component logic?

To stop testing mock behavior, you must verify the actual outcomes and state changes of your components rather than asserting how many times a mock was called. This ensures your unit tests validate real behavior and remain resilient during refactoring.

Why does adding test-only methods to production code cause maintenance issues?

Adding test-only methods to production code causes maintenance issues by polluting the codebase with logic that never runs in production. This increases complexity, obscures the actual business logic, and violates clean code principles.

How does TDD help prevent testing anti-patterns in software development?

TDD prevents testing anti-patterns by forcing you to write tests that drive the design of production code before implementing it. This ensures tests verify necessary behavior naturally, reducing the need for excessive mocking or test-specific production methods.

What should I consider before mocking a dependency in my unit tests?

Before mocking a dependency, you must fully understand its behavior and data structures. Mocking incomplete data structures or poorly understood dependencies causes silent failures and unintended consequences in your test suite.

How do I ensure my mocks contain complete data structures to avoid silent failures?

To ensure complete mocks, you must replicate the full data structure of the actual dependency in your mock objects. This prevents silent failures by ensuring your tests process all fields and data paths the real component would use.