Agent skill · software engineering · affaan-m

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.

Why this skill is useful

Provides specific Rust testing patterns and TDD methodologies that the AI wouldn't reliably generate on its own.

What it needs

Requires cargo installed locally. About 6k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

Rust Testing Patterns Comprehensive Rust testing patterns for writing reliable, maintainable tests following TDD methodology. When to Use Writing new Rust functions, methods, or traits Adding test coverage to existing code Creating benchmarks for performance-critical code Implementing property-based tests for input validation Following TDD workflow in Rust projects How It Works 1. Identify target code — Find the function, trait, or module to test 2. Write a test — Use #[test] in a #[cfg(test)] module, rstest for parameterized tests, or proptest for property-based tests 3. Mock dependencies — Use mockall to isolate the unit under test 4. Run tests (RED) — Verify the test fails with the expected error 5. Implement (GREEN) — Write minimal code to pass 6. Refactor — Improve while keeping tests green 7. Check coverage — Use cargo-llvm-cov, target 80%+ TDD Workflow for Rust The RED-GREEN-REFACTOR Cycle Step-by-Step TDD in Rust Unit Tests Module-Level Test Organization Assertion Macros Error and Panic Testing Testing Result Returns Testing Panics Integration Tests File Structure Writing Integration Tests Async Tests With Tokio Test Organization Patterns Parameterized Tests with rstest Test Helpers Property-Based Testing with proptest Basic Property Tests Custom Strategies Mocking with mockall Trait-Based Mocking Doc Tests Executable Documentation /// use mycrate::add; /// /// asserteq!(add(2, 3), 5); /// asserteq!(add(-1, 1), 0); /// norun /// use mycrate::parseconfig; /// /// let config = parseconfig(r#"port = 8080"#).unwrap(); /// asserteq!(config.port, 8080); /// norun /// use mycrate::parseconfig; /// /// assert!(parseconfig("}{invalid").iserr()); /// Benchmarking with Criterion Test Coverage Running Coverage Coverage Targets Code Type Target ----------- -------- Critical business logic 100% Public API 90%+ General code 80%+ Generated / FFI bindings Exclude Testing Commands Best Practices DO: Write tests FIRST (TDD) Use #[cfg(test)] modules for unit tests Test behavior …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/rust-testing--581898

View the source on GitHub

Browse the @skills marketplace