rust-testing

Write and run Rust unit, integration, property-based, fuzz, and snapshot tests with coverage tooling.

3|Updated Aug 8, 2026
One-click install
npx skills add https://github.com/Jose-Polanco-Oxte/Echos-Live-Music-Visualizer --skill rust-testing-jose-polanco-oxte
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-testing
Source: https://github.com/Jose-Polanco-Oxte/Echos-Live-Music-Visualizer/tree/main/.agents/skills/rust/sub-skills/rust-testing
Command: npx skills add https://github.com/Jose-Polanco-Oxte/Echos-Live-Music-Visualizer --skill rust-testing-jose-polanco-oxte

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Rust developers face a fragmented testing ecosystem — choosing between plain #[test], rstest, proptest, mockall, insta, cargo-fuzz, and cargo-mutants is confusing, and weak test suites pass without actually catching bugs. This Skill provides a decision framework and concrete patterns for every Rust testing scenario. ## Core Features & Use Cases - Tool Selection Guide: A decision table maps each testing situation (async code, table-driven cases, invariants, mocks, snapshots) to the right crate and reference file. - TDD Workflow: Demonstrates the RED-GREEN-REFACTOR loop in idiomatic Rust with todo!() stubs and command cheatsheets for cargo test and nextest. - Quality Gates: Covers coverage with cargo llvm-cov, risk analysis with cargo-crap, mutation testing with cargo-mutants, and a ready-to-use GitHub Actions CI pipeline. - Use Case: When adding tests to a parser that handles untrusted input, follow the guidance to combine proptest invariants with cargo-fuzz targets, then gate the crate at 80% line coverage in CI. ## Quick Start Ask the assistant to write tests for a Rust function using the appropriate testing approach, such as table-driven rstest cases or a proptest invariant.

Frequently Asked Questions about rust-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write async tests in Rust with tokio?

Use #[tokio::test] to spin up a runtime per test, with tokio's macros and rt-multi-thread features enabled as dev-dependencies. For timeout tests, add the test-util feature and use #[tokio::test(start_paused = true)] so paused time auto-advances without real waiting.

What is the difference between proptest and cargo-fuzz in Rust?

proptest asserts invariants over generated structured inputs and shrinks failures to minimal counterexamples. cargo-fuzz throws adversarial bytes at parsers and unsafe code to find panics and memory errors, requiring the nightly toolchain and libFuzzer.

How do I measure Rust test coverage in CI?

Use cargo llvm-cov for source-based LLVM coverage, optionally combined with cargo nextest via cargo llvm-cov nextest. Add --fail-under-lines 80 to gate CI, and export lcov.info for uploaders or cargo-crap risk analysis.

When should I use mockall versus a real implementation in Rust tests?

Use mockall's #[automock] only at true boundaries like network, clock, or payment gateways where running the real dependency is impractical. Prefer a real or in-memory implementation when feasible, since over-mocking tests your mocks instead of your code.

Does cargo nextest run doc tests?

No, cargo nextest does not run doc tests. Run cargo test --doc separately alongside nextest, for example in a distinct CI step after the main nextest coverage run.

How do I verify my Rust tests actually catch bugs?

Use cargo-mutants for mutation testing: it makes small edits like flipping operators or deleting function bodies, then reruns the suite. Surviving mutants reveal assertion gaps; scope runs with --in-diff or -f since it rebuilds per mutant.