affaan-m avatar

Rust Testing

This walks you through the full TDD cycle in Rust, from unit tests with assert macros to integration tests, async testing with Tokio, and property-based testing with proptest. It covers mocking with mockall, parameterized tests using rstest, and organizing test modules properly. The RED-GREEN-REFACTOR examples are practical, showing you how to start with todo!() and build up working code. If you're moving from other languages or just want to stop guessing at Rust test patterns, the coverage tooling suggestions and concrete code samples make this immediately useful. It assumes you know basic Rust but need the testing ecosystem laid out clearly.

skills.sh installs
7.4K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --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/ecc
Categories
Testing & QA, Rust
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263
1forcedotcom avatarplatform-apex-test-generateforcedotcom/sf-skillsGenerate and validate Apex test classes with TestDataFactory patterns, bulk testing (251+ records), mocking strategies, assertion best practices, and discipline7.4Kskills.sh installs
2forcedotcom avatarplatform-apex-test-runforcedotcom/sf-skillsApex test execution, coverage analysis, and test-fix loops with 120-point scoring. Use when the user needs to run Apex tests, check code coverage, fix failing t7.2Kskills.sh installs
3pproenca avatarvitestpproenca/dot-skillsVitest testing framework patterns for test setup, async testing, mocking with vi.*, snapshots, and test performance (formerly test-vitest). This skill should be7.2Kskills.sh installs
4anthropics avatartesting-strategyanthropics/knowledge-work-pluginsDesign test strategies and test plans. Trigger with "how should we test", "test strategy for", "write tests for", "test plan", "what tests do we need", or when 6.7Kskills.sh installs
5analogjs avatarangular-testinganalogjs/angular-skillsWrite unit and integration tests for Angular v20+ applications using Vitest or Jasmine with TestBed and modern testing patterns. Use for testing components with6.6Kskills.sh installs
6affaan-m avatartdd-workflowaffaan-m/eccUse this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and6.4Kskills.sh installs