Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Rust Testing?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/dankosik-rust-testing-cargo-modernize)
---
name: rust-testing
description: "Behavior. Use when writing or reviewing Rust tests: assertions, proving layer, real dependencies, time control, and defect detection."
---
# Rust Testing
**Behavior first.** Name the observable contract a defect would break, select the smallest layer able to watch it fail, and assert concrete user-visible outcomes (reported finding id and span, rendered replacement, `.fixed.rs` output, report JSON, `stderr` bytes, exit code, or untouched working tree) against independent expected values.
**Smallest proving layer.** Match the harness to the boundary under test: unit tests beside pure logic in `cargo-modernize-core`, paired catalog fixtures (`<id>.rs` with `//~ <id>` markers and `<id>.fixed.rs`) plus a negative twin for every rule, metamorphic property tests (`metamorphic_proptest.rs`) for matcher and renderer invariants, and binary-level tests in `crates/cargo-modernize/tests` over `tempfile` workspaces for discovery, MSRV/edition resolution, `--diff`, `--verify`, `--fix`, `--check`, and exit codes. Assert public behavior so internal refactors stay green.
**Real inputs versus doubles.** Exercise real `cargo`, `git`, and parser behavior whenever their semantics belong to the claim (generated workspaces, real repositories for VCS diffs, real `cargo check` for `--verify`/`--fix`); reserve doubles such as the test-only panic detector for injected faults. Cover every supported edition (`2015`–`2024`), `no_std`/`alloc`/`std` variants, MSRV boundaries one release below and at `requires`, and `const` and macro contexts when a rule's admission depends on them.
**Determinism.** Keep output order, paths, and fingerprints independent of thread scheduling, filesystem iteration order, host path separators, and environment; normalize only what the contract declares unstable, and never sleep to synchronize.
**Defect reproduction and discovery.** Organize tests by behavior with small fixtures and explicit boundary limits. Reproduce bugs with a failing test first, verify non-zero executed test counts, and use `cargo mutants`, property tests, Miri, `cargo xtask stress-ui`, or fuzzing selectively as discovery aids rather than mandatory gates.