AGENT SKILL

testing

Test strategy and execution: test-first, isolated unit tests, then integration, then regression; tests assert behaviour, boundaries and errors, never wiring or mock echoes; make test and test.sh for programs, fixture tests for contracts; memory-safe fixtures for large suites. Use when writing tests, choosing what to test, or when a test suite is slow, flaky or runs out of memory.

License 许可
Apache-2.0
最近更新
2026-10-15
Stars
★ 0
Forks
0

01 前言 Front Matter

name
testing
description
Test strategy and execution: test-first, isolated unit tests, then integration, then regression; tests assert behaviour, boundaries and errors, never wiring or mock echoes; make test and test.sh for programs, fixture tests for contracts; memory-safe fixtures for large suites. Use when writing tests, choosing what to test, or when a test suite is slow, flaky or runs out of memory.

02 资源文件 1

03 SKILL.md 正文

Testing

Acceptance criteria come from product.md / plan.md when a feature is active (contract: ${CLAUDE_SKILL_DIR}/../workflow/references/artifacts.md).

TDD law

No production code without a failing test first. Code written before its test is deleted and rewritten after the test fails for the right reason.

Gates (blocking, in order)

  1. Pre-flight: project env and toolchain present (cc, cargo, venv…), dependencies consistent (pip check, lockfile in sync). Broken env → stop and report; do not test around it.
  2. Isolated (unit): 100% pass before running integration.
  3. Integration: 100% pass; contracts match their schema files.
  4. Workflows: every happy path covered end to end.
  5. Browser E2E: zero console errors.
  6. Never loosen a gate, skip a test or exclude code from coverage to go green.

What a test must assert

  • Behaviour: observable output/state, not that a function was called. A test that only re-asserts what a mock returned proves nothing.
  • Every handler has an explicit state assertion; "does not crash" is not a test.
  • Boundaries: empty, min, max, null/missing optional fields.
  • Errors: invalid input, 401, 403, 429 — each yields a clear, specific message and status.
  • Type coercion across boundaries (a string id from a token vs an int id in the DB) — the most common integration failure.
  • Concurrency where it applies (≥5 simulated users), soft-delete visibility, persistence across reload.
  • Synthetic test data; never real credentials.
  • Every RNG is seeded with a fixed, named seed.

Programs and contracts

  • Programs: make test is every program's test entry; CLI behaviour is tested by test.sh: exact stdout for an input, exit code, NAME: stderr prefix.
  • Interactive terminal programs: tmux-driven screen tests in test.sh (see the rust-tui template) and dl-tui snapshots for each designed state.
  • Contracts: each consumer has a test that feeds its fixture copy of the contract example; each producer has a test that its output matches the example format.

Order

  1. Unit tests, no external dependencies.
  2. Integration: API vs schema, DB type conversions, auth flows, contract fixtures.
  3. Workflow/E2E: full CRUD lifecycle, then error paths, then edge cases. Collect console errors:
    const errors = [];
    page.on('console', m => { if (m.type() === 'error') errors.push(m.text()); });
    // after each step
    expect(errors).toHaveLength(0);
    
  4. Risk-based regression — score and run highest first:
    • +20 critical path (auth, payment, data loss)
    • +15 cyclomatic complexity >10
    • +10 changed in the current diff
    • +5 defect history or external dependency

Gates >1 min run in background with output to .logs/tests/<gate>.log.

Failure classification

Classify every failure into exactly one row. Calling a non-failure a failure is itself a defect.

Category Indicators Action
True test failure Assertion fails in a regime the gate is specified to hold; contract violation Reproduce and fix via debug
Implementation bug Code does not meet acceptance criteria Fix with a repro test
Environment Env missing, service down Fix env; do not retry tests
Test bug Flaky (<95% pass rate), non-deterministic Pin seed, fix test, re-run once
Infra / timeout Budget exceeded, network Decompose; retry with backoff, max 2

Never widen a threshold to pass. After 2 retries of a transient failure, stop and report.

Logs

Test logs go to .logs/tests/{unit,integration,e2e}/ (mkdir -p first); never .log files in the project root.

Large suites

Suite slow or OOM, many per-file engines/fixtures, or files >500 lines → follow ${CLAUDE_SKILL_DIR}/references/memory-efficient-testing.md.

Report

Per phase: command run, pass/fail counts, each failure with its category and repro command. Partial results are reported as partial.

04 同仓库更多 Skills

VolkovIlia
VolkovIlia/deadlion-studio

write-plan

Turns approved product/design/architecture artifacts or a clear request into plan.md: small ordered tasks, each with exact files, a test written first and a verification command. Use before implementing anything larger than a one-file change.

★ 0
VolkovIlia
VolkovIlia/deadlion-studio

workflow

Runs the deadlion pipeline (product → design → decompose → architecture → plan → build → review → verify) through plain-text artifacts in .dev-docs/. Use when the user starts a new product, system, feature or multi-step change, or asks what to do next.

★ 0
VolkovIlia
VolkovIlia/deadlion-studio

verify

Evidence before claims: before saying work is done, fixed or passing, run the proving command fresh, read its output and the git diff, and report VERIFIED and NOT VERIFIED items separately. Use before declaring any task complete and after any subagent reports success.

★ 0
VolkovIlia
VolkovIlia/deadlion-studio

ux-design

Designs the user interface of a program at the lowest rung that serves the job — CLI, filter (dmenu/fzf style), terminal UI, native GUI or web — with flows, states, a key map, design tokens kept in config.def and numeric gates per rung, so every UI works alone and embeds; avoids generic AI-looking UI. Includes the dl-contrast checker. Writes design.md. Use when building or changing any user interface, screen, TUI, GUI, component or visual style.

★ 0
VolkovIlia
VolkovIlia/deadlion-studio

unix-design

Designs the internals of one program or sub-project as small single-purpose modules with plain-text interfaces, separated mechanism and policy, and one build/run command each, following the Unix philosophy. Writes arch.md. Use when designing a new feature's architecture inside a program, a CLI, module or data flow; for splitting a system into several programs use decompose.

★ 0
VolkovIlia
VolkovIlia/deadlion-studio

ui-verify

Verifies a running UI against the gates in design.md — web pages in a real browser via the Playwright MCP (screenshots at 375/768/1280 px, console errors, axe scan, touch targets), terminal programs through dl-tui in a headless tmux (screens at 80×24, 40×12 and 20×5, NO_COLOR, key scripts per state, terminal restore, stdout purity), and token contrast with dl-contrast. Use after implementing or changing any UI, or when the user asks to check how a screen looks or works.

★ 0