Rust Testing Patterns — portable workflow
Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology. Use when writing Rust tests — unit, integration, async, property-based, or coverage.
Use it only when the request supplies this domain, framework, data source or artifact; a shared keyword is not a match. Related skills, each for its own concern: bosskuai-kotlin-testing, bosskuai-go-development, bosskuai-fsharp-testing, bosskuai-performance-profiling.
Workflow
Read the source workflow first, then work through these sections in order:
- How It Works.
- TDD Workflow for Rust.
- The RED-GREEN-REFACTOR Cycle.
- Step-by-Step TDD in Rust.
- Unit Tests.
- Module-Level Test Organization.
- Resolve its
scripts/, references/, assets/ and template paths against references/upstream/, not the project root. Source skill names map through SOURCE.json (bossku skills show <id>). ECC slash commands, agent names and package-root paths are not installed: use what this host has, or say what is missing.
- Check the project's tool versions and the source prerequisites first:
rustc --version, cargo --version, the channel pinned in rust-toolchain.toml, rust-version and edition in Cargo.toml, and the test crate versions in Cargo.lock. Check the latest stable Rust release on blog.rust-lang.org at work time. Use only APIs present in the installed version. A documented command is an example, not permission to install packages, add an account, expose secrets, upload private content or change an external service.
- It can need a named provider, MCP server or API: check that it is available and in scope, report it when it is not, and never invent its output.
Done when
Run the affected cargo test target, with failing-before/passing-after evidence when fixing a test or defect.
If an input, provider, runtime or authorisation is missing, stop that step, carry on with read-only analysis, and say exactly what is missing. A generated plan alone is not completion.
- Run the tests in debug and with
cargo test --release, since overflow checks differ. Add --no-default-features runs and the feature sets CI uses. Use --all-features only when the crate builds with it.
- Money in tests is the string production receives (
"0.01"), parsed the same way production parses it, not an f64 literal.
- Async tests (
#[tokio::test]) cover cancellation: dropping a future in select! can lose its unfinished work.
- Full quality bar, with version and type checks:
../../references/checklists/engineering-quality-bar.md.
Adapted from the locally reviewed affaan-m/ECC snapshot: provenance and hashes in SOURCE.json, the original text and resources in references/upstream/ under its MIT licence. Copyright (c) 2026 Affaan Mustafa.
1---2name: bosskuai-rust-testing3description: "Use when the task explicitly concerns rust testing. Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology. Use when writing Rust tests — unit, integration, async, property-based, or coverage."4metadata:5 source: https://skillmd.com/skills/wankimmy/bosskuai-rust-testing6 origin: ECC-adaptation7---89# Rust Testing Patterns — portable workflow1011Rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology. Use when writing Rust tests — unit, integration, async, property-based, or coverage.1213Use it only when the request supplies this domain, framework, data source or artifact; a shared keyword is not a match. Related skills, each for its own concern: `bosskuai-kotlin-testing`, `bosskuai-go-development`, `bosskuai-fsharp-testing`, `bosskuai-performance-profiling`.1415## Workflow1617Read [the source workflow](references/upstream/SKILL.md) first, then work through these sections in order:18191. How It Works.202. TDD Workflow for Rust.213. The RED-GREEN-REFACTOR Cycle.224. Step-by-Step TDD in Rust.235. Unit Tests.246. Module-Level Test Organization.2526- Resolve its `scripts/`, `references/`, `assets/` and template paths against `references/upstream/`, not the project root. Source skill names map through [SOURCE.json](SOURCE.json) (`bossku skills show <id>`). ECC slash commands, agent names and package-root paths are not installed: use what this host has, or say what is missing.27- Check the project's tool versions and the source prerequisites first: `rustc --version`, `cargo --version`, the channel pinned in `rust-toolchain.toml`, `rust-version` and `edition` in `Cargo.toml`, and the test crate versions in `Cargo.lock`. Check the latest stable Rust release on blog.rust-lang.org at work time. Use only APIs present in the installed version. A documented command is an example, not permission to install packages, add an account, expose secrets, upload private content or change an external service.28- It can need a named provider, MCP server or API: check that it is available and in scope, report it when it is not, and never invent its output.2930## Done when3132Run the affected cargo test target, with failing-before/passing-after evidence when fixing a test or defect.3334If an input, provider, runtime or authorisation is missing, stop that step, carry on with read-only analysis, and say exactly what is missing. A generated plan alone is not completion.3536- Run the tests in debug and with `cargo test --release`, since overflow checks differ. Add `--no-default-features` runs and the feature sets CI uses. Use `--all-features` only when the crate builds with it.37- Money in tests is the string production receives (`"0.01"`), parsed the same way production parses it, not an `f64` literal.38- Async tests (`#[tokio::test]`) cover cancellation: dropping a future in `select!` can lose its unfinished work.39- Full quality bar, with version and type checks: `../../references/checklists/engineering-quality-bar.md`.4041Adapted from the locally reviewed `affaan-m/ECC` snapshot: provenance and hashes in [SOURCE.json](SOURCE.json), the original text and resources in [references/upstream/](references/upstream/SKILL.md) under its [MIT licence](references/upstream/LICENSE). Copyright (c) 2026 Affaan Mustafa.