This one walks you through the full TDD cycle in Rust, from basic unit tests with assert macros to property-based testing with proptest and mocking with mockall. It's organized around the RED-GREEN-REFACTOR workflow, so you write failing tests first, implement minimal code to pass, then refactor. The coverage is solid: async tests with tokio, parameterized tests with rstest, integration test structure, and panic testing. If you're coming from other languages and want to see how Rust testing actually works in practice, or you're already writing Rust but want to tighten up your test discipline, this covers the patterns you'll actually use. The code samples are realistic and show both the setup and the assertions you'd write.

skills.sh installs
5.3K
GitHub stars
229.1K
last updated
Jul 14, 2026

Install

$ npx -y skills add affaan-m/everything-claude-code --skill rust-testing --agent claude-code

Installs into .claude/skills of the current project.

Files

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

RED     → Write a failing test first
GREEN   → Write minimal code to pass the test
REFACTOR → Improve code while keeping tests green
REPEAT  → Continue with next requirement

Step-by-Step TDD in Rust

Sponsors

Details

Repository
github.com/affaan-m/everything-claude-code
Categories
Testing & QA, Rust
First seen
Apr 16, 2026

More from affaan-m/everything-claude-code

All 256
1affaan-m avatarlaravel-tddaffaan-m/everything-claude-codelaravel tdd5.1Kskills.sh installs
2affaan-m avatarai-regression-testingaffaan-m/everything-claude-codeai regression testing4.8Kskills.sh installs
3affaan-m avatarkotlin-testingaffaan-m/everything-claude-codekotlin testing4.8Kskills.sh installs
4affaan-m avatarperl-testingaffaan-m/everything-claude-codeperl testing4.5Kskills.sh installs
5affaan-m avatarbrowser-qaaffaan-m/everything-claude-codebrowser qa4.3Kskills.sh installs
6affaan-m avatarcsharp-testingaffaan-m/everything-claude-codecsharp testing3.6Kskills.sh installs