rust-testing

Generates and diagnoses Rust tests using rstest, mockall, tokio, and cargo tooling.

Updated Jul 6, 2026
One-click install
npx skills add https://github.com/chenziyang110/launchdeck --skill rust-testing-chenziyang110
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-testing
Source: https://github.com/chenziyang110/launchdeck/tree/main/.claude/skills/rust-testing
Command: npx skills add https://github.com/chenziyang110/launchdeck --skill rust-testing-chenziyang110

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing thorough Rust tests requires choosing the right framework, mocking strategy, and test layout for each scenario, and mistakes lead to flaky tests, poor coverage, and slow debugging cycles. ## Core Features & Use Cases - Structured Test Generation: Follows a five-phase protocol covering context analysis, strategy selection, test case design, code generation, and verification for unit, integration, doc, and async tests. - Framework Guidance: Provides working examples for rstest fixtures and parametrization, mockall trait mocking, tokio async tests, insta snapshots, and proptest property-based testing. - Failure Diagnosis & Coverage: Includes debugging workflows with backtraces and thread isolation, flaky-test guardrails, and coverage commands using cargo-tarpaulin and cargo-llvm-cov. - Use Case: When asked to add tests for a Rust service with trait-based dependencies, the skill inspects the code, selects mockall for the trait boundary, generates rstest-parametrized tests with edge cases, and outputs the cargo nextest commands to verify them. ## Quick Start Ask the assistant to write unit and integration tests for a specific Rust module using rstest and mockall, then run them with cargo nextest.

Frequently Asked Questions about rust-testing

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

FAQPage Schema
How do I write parametrized tests in Rust?▼

Use the rstest crate with #[rstest] and #[case] attributes to run one test function against multiple input sets. Add rstest to your dev-dependencies and annotate each case with its inputs and expected result.

How do I mock traits in Rust tests?▼

Use mockall's #[automock] attribute on a trait to generate a mock implementation with expectation methods like expect_send, with, times, and return_const. Inject the mock through generics in the code under test.

What is the difference between cargo test and cargo nextest?▼

cargo nextest is a faster parallel test runner with better failure output and per-test process isolation compared to the default cargo test runner. It also supports automatic retries for flaky tests via --retries.

How do I test async Rust code with tokio?▼

Annotate async test functions with #[tokio::test] so tokio provides a controlled runtime for the test. Add tokio with the macros and test-util features to your dev-dependencies.

Why are my Rust tests flaky and how do I fix them?▼

Flakiness usually comes from thread::sleep synchronization, real time or network dependencies, and shared state. Replace sleeps with channels or tokio::time::timeout, use tempfile::TempDir for isolation, and run with --test-threads=1 to detect concurrency issues.

How do I measure Rust test coverage?▼

Install cargo-llvm-cov and run cargo llvm-cov --html for a local report or --lcov to export lcov.info for Codecov. cargo-tarpaulin is an alternative that works on stable Rust.