testing-anti-patterns

Enforce TDD practices and prevent mock-related testing anti-patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Testing anti‑patterns such as asserting on mock behavior, adding test‑only methods to production code, and mocking without full understanding create brittle tests and pollute the codebase.

Core Features & Use Cases

  • Guidance: Clear rules to avoid asserting on mocks and to keep production code free of test‑only methods.
  • Gate Functions: Decision checkpoints that prompt the developer to question mock usage before proceeding.
  • TDD Reinforcement: Emphasizes writing tests first to surface these anti‑patterns early.
  • Use Case: When writing new unit tests for a UI component, the skill helps decide whether a mock is appropriate and prevents adding cleanup methods to production classes.

Quick Start

Ask the AI to review your test suite and highlight any mock‑related anti‑patterns.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
How do I stop unit tests from asserting on mock behavior?

To stop unit tests from asserting on mock behavior, apply strict TDD practices and use decision checkpoints that question mock usage before proceeding. This prevents brittle tests by enforcing clear separation of test utilities and mandating dependency understanding.

Why does mocking without understanding dependencies create brittle tests?

Mocking without understanding dependencies creates brittle tests because it decouples the test from actual system behavior, leading to false positives. Gate functions prompt developers to analyze dependencies first, ensuring mocks accurately reflect real interactions and preventing test-only methods in production code.

What is the best way to keep production code free of test-only methods?

The best way to keep production code free of test-only methods is enforcing strict separation between production logic and test utilities. Applying TDD principles surfaces these anti-patterns early, preventing cleanup methods from polluting production classes during unit test creation.

Can I use TDD practices to identify testing anti-patterns in an existing test suite?

Yes, you can use TDD practices to identify testing anti-patterns by reviewing the test suite to highlight mock-related issues. Decision checkpoints help evaluate whether existing mocks are appropriate and catch instances where test-only utilities were added to production code.

When should I not use mocking in unit tests?

You should not use mocking in unit tests when you lack a clear understanding of the dependency's actual behavior. Uninformed mocking creates brittle tests and pollutes the codebase, so gate functions prompt you to question mock usage and ensure appropriate separation.