rust-testing

Implements Rust unit, integration, async, and property-based tests following TDD methodology.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill rust-testing-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rust-testing
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/rust-testing
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill rust-testing-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Rust tests requires knowing many crates and patterns—rstest, proptest, mockall, tokio test macros, and coverage tooling. This Skill provides structured guidance and code patterns so you can write correct tests quickly and follow a disciplined TDD workflow. ## Core Features & Use Cases - TDD Workflow Guidance: Step-by-step RED-GREEN-REFACTOR cycle with concrete Rust examples using todo!() placeholders. - Comprehensive Test Patterns: Covers unit tests, integration tests, async tests with tokio, parameterized tests with rstest, property-based tests with proptest, and mocking with mockall. - Coverage & CI Integration: Commands for cargo-llvm-cov with coverage targets and a ready-to-use GitHub Actions pipeline including fmt, clippy, and tests. - Use Case: You are building a Rust web service and need to test a repository trait. Use this Skill to generate a mockall-based mock, write parameterized rstest cases, and enforce 80% coverage in CI. ## Quick Start Ask the AI to write tests for a Rust function or module following TDD, for example: write unit tests with mockall mocks and rstest parameterized cases for my UserService.

Frequently Asked Questions about rust-testing

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

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

Place a #[cfg(test)] mod tests block inside the same source file and mark each test function with #[test]. Use assert_eq!, assert_ne!, and assert! macros, then run cargo test to execute them.

How to mock traits in Rust tests with mockall?▼

Annotate the trait with #[automock] from mockall to generate a mock struct. Configure expectations with expect_method(), .with(), .times(), and .returning(), then inject the mock into the service under test.

What is the difference between proptest and rstest in Rust?▼

rstest provides parameterized tests and fixtures where you define explicit cases with #[case]. proptest generates random inputs from strategies to verify properties hold across many values, such as roundtrip or ordering invariants.

Does tokio support async test functions in Rust?▼

Yes, use the #[tokio::test] attribute on an async fn to run it on a Tokio runtime. You can combine it with tokio::time::timeout to test timeout behavior without sleeping.

How do I measure Rust test coverage with cargo-llvm-cov?▼

Install cargo-llvm-cov and run cargo llvm-cov for a summary, --html for a report, or --lcov for CI integration. Use --fail-under-lines 80 to enforce a minimum coverage threshold in pipelines.

When should I avoid #[should_panic] in Rust tests?▼

Avoid #[should_panic] when the function returns a Result, since testing Result::is_err() or matching specific error variants gives more precise assertions. Reserve should_panic for genuine panic paths with an expected message.