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.
- Run the suite one time. Read the output. The output tells you what failed.
- Do not run the same tests again when the code did not change. The result is the same. It is a waste of time and tokens.
- Never run tests in a loop. No
for i in {1..N}, no--count=N, no--repeat, no "run it 10 more times to be sure". - Never run the suite again to "confirm" a pass or a fail. One run is the confirmation.
- When tests fail, work on the failures only. Run only the failing tests after each fix. Run the full suite one more time at the end.
- Redirect the output of the run to a file in the scratchpad. Read or search that file. Do not run the tests again to see the output again.
Unit and integration targets
- Unit tests are fast, and they give coverage. A unit test examines the
code's logic and needs no external system. Unit tests run all the time:
every test run includes every unit target.
- Integration tests can be slower. They exercise real scenarios — a real
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.
- **Selection is platform-native and structural, never an environment
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
- All tests pass. A partial pass is a fail.
- All warnings resolved. Warnings are bugs that haven't bitten yet.
- Skipped tests are broken (fix) or dead (delete) — never acceptable.
- Never silence: no
#[allow(...)],@suppress,// eslint-disable. - Never skip: no
#[ignore]orskipto make a test stop failing. - Never hand-prove a test is non-vacuous: edit source, run, watch it fail, revert. Nothing is captured or re-runnable. If proving it needs perturbing the thing under test, that perturbation is a permanent test case: pin the literal value, not just the symbol (
assert_eq!(CONST, "haiku"), not a compare that resolves both sides through the same symbol), or set an explicit override inside the test and assert the different outcome.
{% include "_partials/findings-are-requirements" %}
Process
- 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.
- Type-check + lint treating warnings as errors.
- Check for skipped/ignored tests — fix or delete each. Skips are not acceptable.
- 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.
- Fix each failure and warning on the list. Trace before editing:
get symbolon the failing function,get callgraph(inbound) to see callers, and — if you're changing a shared symbol —get blastradiuson 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. - 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:
- Rust:
timeout 60 cargo nextest run --test-threads=1 <test_name>— nextest has no--timeoutflag; its per-test budget is config-only viaslow-timeout/terminate-afterin.config/nextest.toml, so wrap the invocation with the shelltimeoutto bound a single suspect test - Python:
pytest --timeout=60(needspytest-timeout) - Node:
jest --testTimeout=60000
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:
- Rust:
#[serial_test::serial];CurrentDirGuard/tempfile::TempDirfor cwd/files - Python:
@pytest.mark.serial;tmp_pathfixture for filesystem - Node:
test.serial(...)(ava); bind port0and read it back
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:
- Iteration over a
HashMap/HashSet/dict/Setwith no sort sleep, a timeout, or a wait on a background task- The system clock, a random number generator with no seed
- A shared port, cwd, env var, or temp file
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.