test-guidelines

Provide test guidelines covering mocking assessment, DI refactoring, and AAA patterns.

9|Updated Jan 31, 2017
One-click install
npx skills add https://github.com/ssiumha/dots --skill test-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-guidelines
Source: https://github.com/ssiumha/dots/tree/main/prompts/skills/test-guidelines
Command: npx skills add https://github.com/ssiumha/dots --skill test-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers overcome the challenges of writing high-quality tests, effectively reviewing existing ones, and efficiently debugging failures. It ensures code reliability and promotes adherence to best practices, saving time and reducing complexity in the development lifecycle.

Core Features & Use Cases

  • Test Creation Workflow: Guides you through analyzing target code, planning test strategies (like AAA pattern), and writing new tests incrementally. Use it when you need to add new features or fix bugs and want to ensure proper test coverage.
  • Test Review & Refactoring: Provides a comprehensive checklist to review existing test code, identify issues such as excessive mocking, lack of independence, or test-bypassing patterns. Ideal for improving code quality and maintainability.
  • Debugging Failed Tests: Offers a structured approach to diagnose and resolve test failures, helping you distinguish between actual implementation bugs and issues within the test itself. Use it when your CI/CD pipeline fails or a local test run shows unexpected results.

Quick Start

Help me write unit tests for the new user authentication module, focusing on happy paths and edge cases.

Frequently Asked Questions about test-guidelines

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

FAQPage Schema
How do I write better unit tests that avoid excessive mocking?

Unit tests should minimize mocks by testing real dependencies when possible. Focus on testing behavior rather than implementation details, use dependency injection for flexibility, and reserve mocks for external services or hard-to-control dependencies. This approach improves test reliability and maintainability.

What's the best way to review existing test code for quality issues?

Review tests using a structured checklist: verify independence between tests, check for over-mocking, ensure the AAA pattern (Arrange-Act-Assert), validate naming clarity, and confirm tests aren't bypassing the code under test. This identifies maintainability problems and hidden bugs.

How do I debug a failing test and determine if it's a code bug or test issue?

Failing tests require systematic diagnosis: isolate the failure, verify test independence, check mock behavior, review assertions, and trace the actual code path. Distinguish between implementation bugs and test-design flaws to fix the root cause efficiently.

What testing patterns should I follow when writing new tests?

Follow the AAA pattern (Arrange-Act-Assert), write independent tests that don't depend on execution order, use clear naming conventions that describe intent, apply fixture and factory patterns for setup, and plan test strategy before writing. This ensures comprehensive coverage and maintainability.

When should I refactor tests to use dependency injection instead of mocking?

Refactor to dependency injection when tests rely on excessive mocks or tight coupling to implementation. DI-based refactoring enables injecting real or stub dependencies, improves test clarity, reduces brittleness, and makes tests easier to maintain as code evolves.

Can I apply test guidelines across new features, existing code, and failing test scenarios?

Yes, test guidelines apply uniformly across all scenarios: creating new tests for features, reviewing and improving existing test suites, and diagnosing failed tests. Consistent workflows ensure code reliability, best-practice adherence, and efficient debugging regardless of context.