testing-unit-integration

Write and audit unit and integration tests using six critical rules.

Updated Jul 1, 2025
One-click install
npx skills add https://github.com/agdev/claude-code --skill testing-unit-integration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-unit-integration
Source: https://github.com/agdev/claude-code/tree/main/skills/testing-unit-integration
Command: npx skills add https://github.com/agdev/claude-code --skill testing-unit-integration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Writing clean, effective unit and integration tests is challenging, often leading to flaky tests, poor coverage, and high maintenance costs. This Skill provides expert guidance to ensure your tests are simple, consistent, and reliable, saving development time and reducing debugging efforts.

Core Features & Use Cases

  • 6 Critical Rules: Enforces strict guidelines (e.g., max 10 statements, flat structure) for test quality and maintainability.
  • Data Factories & Mocking: Guides on creating realistic test data and implementing effective mocking strategies for isolated testing.
  • Domain-Specific Testing: Covers best practices for DOM, database, and API testing, ensuring comprehensive coverage across layers.
  • Use Case: Review an existing test suite to identify violations of best practices, or write new tests following a clear, consistent pattern that guarantees reliability and reduces future refactoring pain.

Quick Start

Review the attached user-service.test.ts file and report any violations of the 6 Critical Rules for unit testing.

Frequently Asked Questions about testing-unit-integration

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

FAQPage Schema
What are the 6 critical rules for writing unit and integration tests?

The 6 critical rules enforce test quality through max 10 statements per test, essential details only, flat structure, full coverage across layers, smoking gun assertions that prove the behavior, and self-contained tests with no external dependencies. These rules reduce flakiness, maintenance costs, and improve reliability.

How do I write unit tests that follow best practices and avoid common violations?

Structure tests using the AAA pattern (Arrange, Act, Assert), keep statements under 10, use data factories for realistic test data, implement effective mocking strategies for isolation, and write assertions that directly prove the expected behavior. This approach ensures tests are maintainable, reliable, and easy to refactor.

Can I use this approach for testing APIs, databases, and DOM interactions?

Yes. The Skill covers domain-specific testing best practices for API endpoints, database operations, and DOM interactions. Each domain has tailored guidance on mocking strategies, assertion patterns, and coverage techniques while maintaining the 6 critical rules.

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

Audit tests against the 6 critical rules: check statement count, verify essential details are present, ensure flat structure, confirm full layer coverage, validate assertions prove behavior, and confirm tests are self-contained. The Skill identifies violations and guides refactoring to meet best practices.

Why do my unit tests become flaky and hard to maintain over time?

Flaky tests often violate best practices: too many statements, unclear assertions, external dependencies, inadequate mocking, or poor data setup. The 6 critical rules prevent these issues by enforcing simplicity, isolation, and clarity, reducing maintenance burden and debugging time.

Does this Skill apply to end-to-end testing or only unit and integration tests?

This Skill focuses on unit, integration, component, microservice, and API tests. It does not cover end-to-end tests, which have different patterns and scope. Use it for isolated layer testing where the 6 critical rules ensure reliability.