AI Skill MartBrowse skillsPromptsProgramsLearnWhat is a Skill?
← Back to list

Rust Testing Patterns

A TDD-driven reference for writing Rust unit, integration, async, property-based and mocked tests with coverage targets.

Dev & CodingIntermediate★ 497⑂ 55AI score 9/10Last updated: Nov 24, 2026

What it does

  • Walks Claude through the RED → GREEN → REFACTOR cycle in Rust, using todo!() placeholders to start from a failing test.
  • Provides concrete patterns for #[cfg(test)] unit tests, tests/ integration binaries, and #[tokio::test] async tests including timeouts.
  • Covers rstest (parameterized cases and fixtures), proptest (roundtrip properties, custom strategies), mockall (trait mocking with expectations), and criterion benchmarks.
  • Adds coverage workflow with cargo llvm-cov, per-code-type targets (100% critical logic, 90%+ public API, 80%+ general), and a GitHub Actions job.
  • Includes a practical DO/DON'T list: no sleep() in tests, prefer assert_eq!, never skip error paths.

Who it's for

  • Rust developers raising test coverage on libraries or services.
  • Engineers adopting TDD and wanting a concrete Rust playbook.
  • Teams testing tokio-based async code or dependency-heavy service layers.
  • Teams enforcing coverage gates in CI.

Examples

  1. "Add TDD tests for parse_config, including error variants" → a failing test is written first, then a minimal implementation.
  2. "Mock the UserRepository trait with mockall to test the service layer" → generates #[automock] plus expect_find_by_id().with(eq(42)) expectations.
  3. "Verify encode/decode roundtrip with proptest and fail CI under 80% coverage" → produces a proptest! block and cargo llvm-cov --fail-under-lines 80 step.

· · · Install guide · · ·

Try it now, no install

Paste this into Claude to use the skill without installing anything.

Read the instructions in this file and follow them to help me:
https://raw.githubusercontent.com/aiskillstore/marketplace/HEAD/pending/affaan-m/rust-testing/SKILL.md

What I want: (describe your task here)

If Claude can't open the link, open it yourself and paste the contents instead.

↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.

Install in the Claude app (no terminal)
  1. Download the ZIP with the button below.
  2. In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
  3. Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
↓ Download ZIP
Install in Claude Code

Let Claude do it — paste this into Claude Code

Install the skill I found on AI Skill Mart.
Copy the pending/affaan-m/rust-testing folder from the GitHub repo aiskillstore/marketplace into my ~/.claude/skills/rust-testing/.
When it's done, tell me in one line what this skill can do.

Install with a command instead

git clone https://github.com/aiskillstore/marketplace.git /tmp/aiskillstore && mkdir -p ~/.claude/skills/rust-testing && cp -r /tmp/aiskillstore/pending/affaan-m/rust-testing/* ~/.claude/skills/rust-testing/

⚠ This is a third-party skill. Check the source repository before installing.

  1. Open a terminal.
  2. Clone the marketplace repo: git clone https://github.com/aiskillstore/marketplace.git /tmp/aiskillstore
  3. Create the skill folder: mkdir -p ~/.claude/skills/rust-testing
  4. Copy the files: cp -r /tmp/aiskillstore/pending/affaan-m/rust-testing/* ~/.claude/skills/rust-testing/
  5. Restart Claude Code and confirm rust-testing appears in your skill list.
  6. In any Rust project, ask something like "write tests for this module" to trigger the skill.
  7. Prepare the tooling: run cargo install cargo-llvm-cov and add rstest, proptest, mockall, and criterion to [dev-dependencies] in Cargo.toml.