Testing best practices

From alleneubank/claude-code · View interactive version

Testing best practices is an AI agent skill from the GitHub repository alleneubank/claude-code. Use when designing tests, writing test cases, or planning test strategy for a module. Covers unit, integration, and e2e layering.

How to use this skill

Skill file

Test layering policy

Unit tests

Purpose: verify individual functions and invariants in isolation.

Integration / contract tests

Purpose: verify interactions between components and external services.

E2E tests

Purpose: verify real user workflows through the full stack.

Hard rules

Execution guidance

Preflight checks (before e2e)

  1. Verify the target environment is reachable (health endpoint, ping).
  2. Confirm required services are running (database, API, auth provider).
  3. Validate test user / credentials exist and are functional.
  4. Check for leftover state that could cause false failures; log it, do not fail on it.

Deterministic fixtures

Async handling

Flake handling

API surface discovery

Before generating test cases:

Output format

Use markdown. Produce three sections:

Test Strategy -- one bullet per layer (unit/integration/e2e) naming the functions/flows and their coverage type.

Test Matrix -- table per function: columns ID | Category | Name | Input | Expected. Case ID scheme: {CATEGORY}-{NN} (HP, BV, ERR, EDGE). Append-only; never renumber.

Implementation Plan -- ordered steps: fixtures, unit tests, integration tests, e2e flows, run command.

CI guidance

Fast PR smoke lane

Nightly full lane

Full unit + integration + e2e suite with higher property-based iteration counts. Flag tests that pass on retry but failed initially.

Workflow

  1. Spec or code defines the module behavior (types, constraints, API surface).
  2. Agent (with this skill) produces test strategy, matrix, and implementation plan.
  3. test-writer agent translates the plan to runnable code in the target language's idiom.
  4. Developer implements to pass the tests.
  5. If implementation reveals missing cases, propose them first; append to spec only when explicitly requested.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.