MCPInstall

testing-best-practices

Use when designing tests, writing test cases, or planning test strategy for a module. Covers unit, integration, and e2e layering.

Installs
218
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/alleneubank/claude-code --skill testing-best-practices
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads testing-best-practices automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Test layering policy

Unit tests

Purpose: verify individual functions and invariants in isolation.

  • Data-driven: parameterized tables covering happy path, boundary, error, and edge cases.
  • Property-based: fuzz invariants that must hold across all inputs (e.g., idempotency, sort stability, roundtrip serialization).
  • Derive cases from the module's public API surface: input types/constraints, output shape, error modes, invariants.

Integration / contract tests

Purpose: verify interactions between components and external services.

  • API envelope: request/response shape, status codes, content types, pagination.
  • Error contract: error codes, error shapes, rate limiting, retries.
  • Auth and scoping: token validation, role-based access, tenant isolation.
  • Eventual consistency: verify convergence within bounded time; poll rather than sleep.
  • Reuse auth state across tests where possible; avoid redundant login flows.

E2E tests

Purpose: verify real user workflows through the full stack.

  • No mocks; exercise real services, databases, and APIs.
  • Happy-path workflows only; save edge cases for lower layers.
  • State-tolerant: never assume a clean slate; tolerate and work with prior state.
  • Idempotent: safe to run repeatedly without cleanup between runs.
  • Flow-oriented: validate real data paths end-to-end rather than isolated assertions.

Hard rules

  • Never invent signatures, source locations, or line numbers. Only reference what you have read from the codebase.
  • No fabricated fixtures. Derive test data from actual schemas, types, or seed data in the repo.
  • No test-only hacks in product code. No if (process.env.TEST) branches, no test-specific exports, no test backdoors.
  • E2E must not rely on clean slate. Tests must tolerate pre-existing data, prior test runs, and shared environments.

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

  • Use seeded randomness for generated data (seeded faker, deterministic UUIDs).
  • Fixtures should be self-contained; avoid cross-test fixture dependencies.
  • Prefer factory functions over shared mutable fixture objects.

Async handling

  • Poll with bounded timeout and backoff; never use fixed sleep/waitForTimeout.
  • Set explicit timeout per operation; fail fast with a descriptive message on timeout.
  • Bound retry attempts (e.g., max 3 retries with exponential backoff).
  • Use framework-native waiting (Playwright expect, async assertions) over manual loops.

Flake handling

  • Single infrastructure retry per test run; if it fails twice, it is not flake.
  • On retry failure, collect diagnostics: screenshots, network logs, service health, timestamps.
  • Classify the failure (flaky / outdated / bug) before attempting a fix.
  • Never add arbitrary delays or retry loops as a flake "fix."

API surface discovery

Before generating test cases:

  • Read the module source to enumerate exports/public functions.
  • Confirm scope from the user request and inspected code context; if ambiguous, state assumptions and proceed conservatively.
  • For each function: input types/constraints, output shape, error modes, invariants.
  • Probe for state dependencies and ordering constraints between functions.

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

  • Unit tests + linting + type-check on every PR.
  • Subset of integration tests covering critical contracts.
  • Target: under 5 minutes.

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.

FAQ

What does the testing-best-practices skill do?

Use when designing tests, writing test cases, or planning test strategy for a module. Covers unit, integration, and e2e layering.

How do I install testing-best-practices?

Run npx skills add https://github.com/alleneubank/claude-code --skill testing-best-practices in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/testing-best-practices/ (personal) or .claude/skills/testing-best-practices/ (project).

Which AI agents can use testing-best-practices?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is testing-best-practices safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains testing-best-practices?

It is published by alleneubank in alleneubank/claude-code. It has 218 recorded installs.

More from alleneubank/claude-code

View all →

typescript-best-practices

alleneubank/claude-code

Use when reading or writing TypeScript or JavaScript files (.ts, .tsx, .js, tsconfig.json).

react-best-practices

alleneubank/claude-code

Use when reading or writing React components (.tsx, .jsx files with React imports).

Frontend & Design3.2K installs

python-best-practices

alleneubank/claude-code

Use when reading or writing Python files (.py, pyproject.toml, requirements.txt).

web-fetch

alleneubank/claude-code

Fetches web content as clean markdown by preferring markdown-native responses and falling back to selector-based HTML extraction. Use for documentation, articles, and reference pages at http/https URLs.

Docs & Writing978 installs

nix-best-practices

alleneubank/claude-code

Use when working with Nix flakes, overlays, shell.nix, or flake.nix files.

zig-best-practices

alleneubank/claude-code

Use when reading or writing Zig files (.zig, build.zig, build.zig.zon).

Popular testing & qa skills

View category →

tdd

mattpocock/skills

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

Testing & QA1.2M installs

grilling

mattpocock/skills

Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.

Testing & QA996.2K installs

migrate-to-shoehorn

mattpocock/skills

Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.

Testing & QA484.1K installs

run-train

lllllllama/rigorpilot-skills

Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.

Testing & QA337.8K installs

test-driven-development

obra/superpowers

Use when implementing any feature or bugfix, before writing implementation code

Testing & QA261.8K installs

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

Testing & QA216.8K installs