rust-testing
Use when writing or running Rust unit tests with cargo or nextest. Apply for crate-level tests that live beside modules, smoke tests for new crates, or when choosing cargo test vs cargo nextest. Do no
SKILL.md.claude/skills/rust-testing/SKILL.md
GitHubRust testing
Purpose
Generic cargo/nextest unit-test conventions for rust-stack projects. Prefer the repo's TEST_CMD
from AGENTS.md when it is more specific.
When to Use
- Adding or changing crate-level Rust tests.
- Choosing
cargo testvscargo nextest run. - Placing tests beside a module or under
tests/.
Do not use this skill for product-specific GUI, TUI, or integration harnesses. Those belong in repo-local skills.
Required Tools
cargocargo nextestwhennextest.tomlor.config/nextest.tomlexists- The project
TEST_CMDfromAGENTS.md
Workflow
- Read
AGENTS.mdfor the canonical test command. Ifnextest.tomlexists, prefercargo nextest run; otherwisecargo test. - Put unit tests next to the module (
*_tests.rsor an inline#[cfg(test)]module) unless the crate already usestests/integration tests. - Run the narrowest command first (
cargo test <name>orcargo nextest run -E 'test(<name>)'). - Keep one behavior per test; cover error paths, not only the happy path.
Agent-Safe Patterns
- Do not disable or weaken tests to go green.
- Do not run workspace-wide test suites when a single crate or filter is enough.
- Format/clippy stay on the lint skill (
cargo fmt --check,cargo clippy).
Verification Checklist
- Used the repo
TEST_CMDor a documented subset - Targeted test failed for the intended reason before the fix (when adding coverage)
- Targeted test passed after the change
Resolve helper paths from this skill directory. Run project commands from the target workspace.