testing-anti-patterns

Detect and prevent testing anti-patterns in unit tests.

6|1|Updated Oct 23, 2025
One-click install
npx skills add https://github.com/alexsandrocruz/ZenPowers --skill testing-anti-patterns-alexsandrocruz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/alexsandrocruz/ZenPowers/tree/main/skills/testing-anti-patterns
Command: npx skills add https://github.com/alexsandrocruz/ZenPowers --skill testing-anti-patterns-alexsandrocruz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid common mistakes in test writing that lead to unreliable, brittle, or misleading tests. It ensures your tests verify actual behavior, not just mock interactions, preventing false confidence in your codebase.

Core Features & Use Cases

  • Mock Behavior Prevention: Guides against testing mocks instead of the actual component behavior, ensuring tests are meaningful.
  • Production Code Purity: Prevents adding test-only methods to production classes, keeping your codebase clean and focused.
  • Dependency Understanding: Ensures you fully understand dependencies before mocking, avoiding broken test logic and mysterious failures.
  • Use Case: When writing new tests or refactoring existing ones, use this Skill to identify and correct anti-patterns that compromise test quality and reliability.

Quick Start

Before asserting on any mock element, ask:

"Am I testing real component behavior or just mock existence?"

If testing mock existence, STOP. Test real behavior instead.

Example of a bad assertion (testing mock):

mockSidebar.Verify(x => x.IsVisible, Times.Once);

Example of a good assertion (testing real behavior):

Assert.Contains("navigation", result.Content);

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
How do I avoid testing mock behavior instead of real component behavior?

Testing mock behavior means asserting on mock interactions rather than actual results. Instead, verify the real output or side effects of your component. For example, assert on returned content or state changes, not on whether a mock method was called.

Why shouldn't I add test-only methods to production code?

Test-only methods pollute production code with logic that serves no real purpose, increasing complexity and maintenance burden. Keep production classes focused on business logic; extract test helpers into separate test utilities instead.

What happens when I mock a dependency without understanding it?

Mocking without understanding dependencies leads to broken test logic and mysterious failures because your mock doesn't reflect the real dependency's behavior. Before mocking, verify what the dependency actually does and what contract it enforces.

How do I write unit tests that actually verify real behavior?

Write tests that exercise your component with real inputs and assert on observable results—return values, state changes, or side effects—rather than mock interactions. This ensures your tests catch actual failures, not just mock configuration issues.

When should I refactor existing tests for anti-patterns?

Refactor tests during code review, maintenance, or when tests fail mysteriously. Prioritize tests that mock heavily or include test-only production methods, as these pose the highest risk of false confidence and brittle behavior.