testing-anti-patterns

Identify and remediate testing anti-patterns in unit and integration tests.

3|2|Updated Oct 10, 2025
One-click install
npx skills add https://github.com/liauw-media/CodeAssist --skill testing-anti-patterns-liauw-media
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/liauw-media/CodeAssist/tree/main/skills/testing/testing-anti-patterns
Command: npx skills add https://github.com/liauw-media/CodeAssist --skill testing-anti-patterns-liauw-media

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill prevents common testing mistakes that lead to fragile tests, false confidence, and bugs slipping into production, ensuring your test suite provides genuine protection and value. It helps you build a robust and reliable testing strategy.

Core Features & Use Cases

  • Five Iron Laws of Testing: Guides you to avoid critical anti-patterns like testing mock behavior, creating test-only methods, and neglecting integration or error path testing.
  • Anti-Pattern Recognition: Helps you identify red flags in existing tests, such as high mock-to-assertion ratios or tests breaking on refactoring, indicating underlying issues.
  • Use Case: When reviewing a test that only verifies mock method calls, this skill will highlight it as "Never Test Mock Behavior" and guide you to rewrite it to assert on actual system behavior, ensuring the test truly validates functionality.

Quick Start

I'm reviewing a new test suite. Use the testing-anti-patterns skill to identify any critical mistakes.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
Why do tests that only verify mock calls fail to catch real bugs?

Testing mock behavior instead of actual system behavior creates false confidence. Tests that assert only on mock method calls don't validate whether your code actually works—they validate the test's own setup. Real bugs slip through because mocks don't replicate production behavior, dependencies, or integration points where failures occur.

How do I identify testing anti-patterns in code review?

Look for red flags: tests that break on refactoring, high mock-to-assertion ratios, test-only methods added to production code, and missing error-path coverage. These patterns indicate tests verify implementation details rather than behavior. Review whether tests assert on actual system outputs and whether mocks are necessary or masking real issues.

What's the difference between unit and integration testing, and why do I need both?

Unit tests isolate components to verify individual logic; integration tests validate how components interact in realistic conditions. Unit tests alone miss integration failures, data flow problems, and dependency issues. Combining both ensures tests catch bugs that occur only when components work together, not just in isolation.

When should I mock dependencies versus testing them directly?

Mock only external dependencies you don't control (third-party APIs, databases) after understanding their behavior. Never mock to avoid writing integration tests or to test behavior you don't understand. If you're mocking because the code is hard to test, refactor the design. Direct testing catches integration bugs that mocks hide.

How do I ensure error paths are properly tested?

Error-path testing validates that your code handles failures correctly. Write tests for each failure scenario: network timeouts, invalid inputs, missing resources, and dependency failures. Don't rely on happy-path tests; deliberately trigger errors and assert the code responds appropriately, including recovery logic and error messages.

Why are test-only methods a code smell?

Test-only methods expose internal implementation to tests, making tests brittle and tightly coupled to code structure. When you refactor, these tests break even if behavior hasn't changed. Tests should verify external behavior, not internal structure, ensuring they remain stable through refactoring and catch real regressions.