Skip to content
Back to skills

Rust Testing

ASecurity

Use when rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology. Only for Rust — not for other languages. Triggers on \"rust-testing\", \"rust testing\", \"testing\".

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 19, 2026
ai-agentspythonrustgokotlintestingperformance

Security analysis

A100/100

Pro scans all 13 files and shows the line behind each finding

Scanned September 19, 2026

npx -y skills add majinmagros/magros.ai-skills --skill rust-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rust Testing?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rust Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majinmagros-rust-testing/badge)](https://www.skillsdirectory.com/skills/majinmagros-rust-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rust-testing
description: "Use when rust testing patterns including unit tests, integration tests, async testing, property-based testing, mocking, and coverage. Follows TDD methodology. Only for Rust — not for other languages. Triggers on \"rust-testing\", \"rust testing\", \"testing\"."
metadata:
  origin: ECC
---

# 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

## When NOT to Use

- Other languages (use `golang-testing`, `python-testing`, `kotlin-testing`, etc.)
- Rust idioms and patterns in general (use `rust-patterns`)

## 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%+

## Contents

| Topic | Reference |
|---|---|
| TDD RED-GREEN-REFACTOR cycle | `references/tdd-workflow.md` |
| Unit tests and assertion macros | `references/unit-tests.md` |
| `Result` and panic testing | `references/error-panic-testing.md` |
| Integration tests | `references/integration-tests.md` |
| Async tests (Tokio) | `references/async-tests.md` |
| Parameterized tests, helpers | `references/test-organization.md` |
| Property-based testing (proptest) | `references/property-testing.md` |
| Mocking (mockall) | `references/mocking.md` |
| Doc tests | `references/doc-tests.md` |
| Benchmarking (Criterion) | `references/benchmarking.md` |
| Coverage (cargo-llvm-cov) | `references/coverage.md` |
| CI integration | `references/ci-integration.md` |

## Example

```rust
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn parses_valid_input() {
        assert_eq!(parse("42").unwrap(), 42);
    }

    #[test]
    fn rejects_invalid_input() {

Files in this skill

  • SKILL.md2.3 KB
  • references/async-tests.md507 B
  • references/benchmarking.md601 B
  • references/ci-integration.md493 B
  • references/coverage.md527 B
  • references/doc-tests.md705 B
  • references/error-panic-testing.md801 B
  • references/integration-tests.md663 B
  • references/mocking.md876 B
  • references/property-testing.md1.1 KB
  • references/tdd-workflow.md720 B
  • references/test-organization.md874 B
  • references/unit-tests.md1.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…