Test

From swissarmyhammer/swissarmyhammer · View interactive version

Test is an AI agent skill from the GitHub repository swissarmyhammer/swissarmyhammer. Run tests and analyze results. Use when the user wants to run the test suite or test specific functionality.

How to use this skill

Skill file

Test

Zero failures. Zero warnings. Zero skipped. The build is clean or it's broken.

Run Tests One Time

A test run is a measurement. Take it one time. Then act on the result.

Unit and integration targets

code's logic and needs no external system. Unit tests run all the time:

every test run includes every unit target.

model, a real database, a real server. They run in CI, and when you judge a

run is appropriate — above all when your change targets that integration.

Then select that integration target directly with the platform test tool —

for example cargo test --test <name> or cargo test -p <crate> (Rust),

swift test --package-path IntegrationTests (Swift),

pytest tests/integration/, or go test ./integration/.... Otherwise

leave them to CI.

variable.** An integration test lives in its own target or package that the

default test command does not see. Select tests only with the platform's

own filtering and selection methods — targets, packages, paths, registered

markers. Never set or read an environment variable to select, skip, or

switch tests.

{% include "_partials/test-design" %}

Guidelines

{% include "_partials/findings-are-requirements" %}

Process

  1. Run the full test suite one time using project detection to pick the right command. The full suite is every unit target. Add the integration targets your change touches; CI runs all of them.
  2. Type-check + lint treating warnings as errors.
  3. Check for skipped/ignored tests — fix or delete each. Skips are not acceptable.
  4. Make a list of the failures and warnings from the output of step 1. This list is your work. Do not run the suite again to make the list.
  5. Fix each failure and warning on the list. Trace before editing: get symbol on the failing function, get callgraph (inbound) to see callers, and — if you're changing a shared symbol — get blastradius on the file to spot passing tests elsewhere that the change could break. After a fix, run only the tests that failed, one time. Do not run the full suite after each fix.
  6. Run the full suite one final time when the list is empty. If new failures show, go to step 4 with only those failures.

Report

{% include "_partials/step-record" %}

Test reports green, red, or stuck. The evidence is the command and its counts.

step: test
outcome: green
evidence: cargo nextest run — 1284 passed, 0 failed, 0 skipped; cargo clippy -- -D warnings clean
task: none

Test does not touch the kanban board. It takes no task id, it writes no comment, and it moves no card. It returns the block, and the caller — /finish, /implement, or the user — records the outcome on the card. This keeps /test usable on a repository with no board.

Report green only after a full run passes. A run that was narrowed to one test, or that ended early, is not green — say what you ran.

Troubleshooting

No Tests

Make one to get started.

A single test hangs and the suite never finishes

Test waits on something CI can't deliver (network, child process, file watcher, deadlock). Run with a hard per-test timeout and isolate the offender with the shell timeout command:

Re-run the offending test with RUST_LOG=trace / --verbose to find the wait, fix the underlying cause.

Tests pass locally, fail in parallel ("address in use", missing files)

Tests share mutable state — cwd, env var, fixed port, shared temp file. Serialize with the project's isolation primitive, don't disable parallelism globally:

Never permanently set --test-threads=1 — it masks the bug.

Flaky test (fails one time, passes another time)

Non-determinism — timing, unordered iteration, clock, external state. Do not run the test in a loop to find it. Read the test and the code under test. Find the source of the non-determinism in the code:

Remove the source (sort iteration, inject a clock, seed RNGs, wait on a signal, not a timer) — don't add retries. Then run the test one time.

Unrelated Failures

No such thing, your job is to thoughtfully fix all failing tests.

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.