Skip to content
Skills Library
Programming · Testing

rust-testing-quality

/rust-testing-quality

Use when writing, organizing, or running Rust tests — unit, integration, doc-tests, proptest, criterion benchmarks, or cargo-mutants. Not for CI pipeline wiring (rust-tooling-cicd).

Repository
agents ↗
Licence
MIT
Last repository change
12.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
6
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use when writing, organizing, or running Rust tests — unit, integration, doc-tests, proptest, criterion benchmarks, or cargo-mutants. Not for CI pipeline wiring (rust-tooling-cicd).

Original author description

Use when writing, organizing, or running Rust tests — unit, integration, doc-tests, proptest, criterion benchmarks, or cargo-mutants. Not for CI pipeline wiring (rust-tooling-cicd).

How it works

  1. Agent Workflow (MANDATORY)
  2. Overview
  3. Critical Rules
  4. Architecture
  5. Reference Guide
  6. Quick Reference
  7. Best Practices
Original SKILL.md headings · 127 lines, 645 words
SKILL.md preview
---
name: rust-testing-quality
description: Use when writing, organizing, or running Rust tests — unit, integration, doc-tests, proptest, criterion benchmarks, or cargo-mutants. Not for CI pipeline wiring (rust-tooling-cicd).
versions:
  cargo-nextest: "0.9"
  proptest: "1"
  criterion: "0.8"
user-invocable: false
references: references/test-organization.md, references/property-and-mutation.md, references/templates/test-suite.md, references/templates/criterion-bench.md
related-skills: solid-rust, rust-tooling-cicd
---

<objective>
This skill covers organizing and running the full Rust test spectrum: unit tests in
#[cfg(test)] modules, integration tests in tests/*.rs against the public API only,
doc-tests compiled from /// examples, property-based testing with proptest (including
committing proptest-regressions/), criterion benchmarks (harness = false), and mutation
testing with cargo-mutants as a scheduled quality gate rather than a per-push check.

It also covers the nextest doctest pitfall: `cargo nextest run` never runs doc-tests, so
`cargo test --doc` must always be paired alongside it — a green nextest run alone is not
full coverage.

Out of scope: CI pipeline wiring and gate ordering belong to rust-tooling-cicd; non-Rust
test suites are not covered.
</objective>

# Rust Testing & Quality

## Agent Workflow (MANDATORY)

Before ANY test work, spawn 3 agents in parallel, one `Agent` call each with a `name`:

1. **fuse-ai-pilot:explore-codebase** - Map existing `tests/`, `#[cfg(test)]`, `benches/`
2. **fuse-ai-pilot:research-expert** - Verify current nextest/proptest/criterion docs via Context7/Exa
3. **mcp__context7__query-docs** - Check crate-specific API (proptest strategies, criterion groups)

After implementation, run **fuse-ai-pilot:sniper** for validation.

---

## Overview

| Test kind | Location | Runs the code as |
|-----------|----------|------------------|
| **Unit** | `#[cfg(test)] mod tests` inside the source file | Same crate, sees private items |
| **Integration** | `tests/*.rs` (each file = own crate) | External consumer, public API only |
| **Doc-test** | ` ```rust ` blocks in `///` docs | Compiled + run as examples |
| **Property** | proptest, inside unit or integration | Generated random inputs + shrinking |
| **Benchmark** | `benches/*.rs` with criterion | Statistical timing, not correctness |

---

## Critical Rules

1. **nextest does NOT run doc-tests** - `cargo nextest run` skips them by design. ALWAYS pair with `cargo test --doc`. Never treat a green nextest run as full coverage.
2. **Integration tests see only the public API** - if a test needs private items, it belongs in `#[cfg(test)]`, not `tests/`.
3. **Commit `proptest-regressions/`** - persisted failing seeds must be under version control so failures are reproducible.
4. **`harness = false` for criterion benches** - required in `Cargo.toml`, or the built-in bench harness collides.
5. **Mutation testing is a gate, not a smoke test** - `cargo mutants` is slow; run it in scheduled CI, not on every push.

---

## Architecture

```
my_crate/
├── src/
│   └── lib.rs            # unit tests in #[cfg(test)] + doc-tests in ///
├── tests/
│   └── api.rs            # integration tests (public API)
├── benches/
│   └── throughput.rs     # criterion, harness = false
└── proptest-regressions/ # committed failing seeds
```

→ See [test-suite.md](references/templates/test-suite.md) for the complete example

---

## Reference Guide

### Concepts

| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| **Test organization** | [test-organization.md](references/test-organization.md) | Deciding unit vs integration vs doc, running with nextest |
| **Property & mutation** | [property-and-mutation.md](references/property-and-mutation.md) | Adding proptest strategies or cargo-mutants |

### Templates

| Template | When to Use |
|----------|-------------|
| [test-suite.md](references/templates/test-suite.md) | Scaffolding unit + integration + doc + proptest |
| [criterion-bench.md](references/templates/criterion-bench.md) | Adding a criterion benchmark |

---

## Quick Reference

### Run everything (the correct pair)

```bash
cargo nextest run --all-features   # unit + integration, fast, parallel
cargo test --doc                   # doc-tests — NOT covered by nextest
```

### Property test skeleton

```rust
use proptest::prelude::*;

proptest! {
    #[test]
    fn round_trips(n in 0u32..10_000) {
        prop_assert_eq!(decode(&encode(n)), n);
    }
}
```

→ See [test-suite.md](references/templates/test-suite.md) for the full file

---

## Best Practices

### DO
- Run `cargo nextest run` + `cargo test --doc` together in every CI gate
- Keep integration tests black-box against the public API
- Start proptest with the cheapest property: "does not panic"
- Name benches by the operation measured, not the function name

### DON'T
- Assume nextest covered doc-tests — it never does
- Put timing benchmarks in `#[test]` (use criterion in `benches/`)
- Gitignore `proptest-regressions/` — commit it
- Run `cargo mutants` on every push (schedule it instead)
Files in this package (6)
  • .gitkeep 1 KB
  • SKILL.md 5 KB
  • references/property-and-mutation.md 4 KB
  • references/test-organization.md 4 KB
  • references/templates/criterion-bench.md 2 KB
  • references/templates/test-suite.md 2 KB

Versions

The database has no other skills named rust-testing-quality.

Database snapshot: 13.11.2026 · package version 680f76faca60 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100rust-testing
    Write and run Rust tests using cargo test with unit tests, integration tests, doc tests, and property-based testing. Use when writing Rust tests or setting up test infrastructure.
  • 90rust-testing
    Testing beyond cargo test for Cybercore Rust apps. Use for unit tests, integration tests, tokio tests, temp dirs, and proptest. Do not weaken tests to make a change pass.
  • 100cargo-test
    Expert Cargo test assistance covering Rust unit tests, integration tests, and benchmarks. Use when running `cargo test`, writing unit tests in Rust, or debugging test failures.
  • 100rust-testing
    Rust testing with cargo test, tokio-test, and mockall. Covers unit tests, integration tests, async testing, mocking, and benchmarks. USE WHEN: user mentions "rust test", "cargo test", "mockall", asks about "#[test]", "#[tokio::test]", "proptest", "criterion", "async rust…
  • 100rust-testing
    Rust testing conventions and frameworks: built-in #[test], integration, and doctest layout plus the cargo-nextest runner and the proptest, insta, criterion, mockall, and rstest ecosystem. Invoke whenever task involves any interaction with Rust tests — writing, running,…
  • 95rust-testing
    Design Rust tests that catch real regressions — unit, integration, doc, property, snapshot, and golden tests, and differential tests that prove a port matches its source. Use when writing or reviewing Rust tests, when a change lands without tests, when deciding what form a test…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.