Skip to content
pproenca avatar

Rust Write Tests

Expert Rust testing guide covering the "What Could Break?" framework, five test transformations, and flake hunting.

CCM score
56 of 100
skills.sh installs
262
GitHub stars
228
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers the "What Could Break?" framework, five test transformations, flake hunting, intent-based assertions, and naming conventions
  • Includes a flake hunting protocol with a stress-test command (cargo nextest run ... --stress-count 50) and event-driven synchronization patterns
  • Enforces whole-object assertions, sibling _tests.rs files, typed factory fixtures, and BTreeMap for deterministic output
  • Designed for Rust developers writing new tests or improving test quality and coverage in existing suites

Install

$ npx -y skills add pproenca/dot-skills --skill rust-write-tests -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Rust Test Writing Skill

Write tests that catch real bugs. Every test must guard a specific invariant -- not just prove the code "works."

The "What Could Break?" Framework

Before writing any test, answer these four questions:

  1. What invariant does this code maintain? (e.g., "deserialized config always has a default profile")
  2. What edge case would violate it? (e.g., "empty TOML table, missing key, extra unknown key")
  3. What platform difference could surface? (e.g., "path separators, case sensitivity, symlink behavior")
  4. What would a future refactor accidentally break? (e.g., "field added to struct but not to Display impl")

If you can only answer #1, your test is a happy-path test. Answer all four and you have a regression suite.

The 5 Test Transformations

Each transformation shows a superficial test pattern and its expert replacement.

Transformation 1: Weak assertions -> whole-object comparison

// BEFORE: proves nothing about the rest of the struct
let result = parse_config(input)?;
assert!(result.is_ok());

Details

Repository
github.com/pproenca/dot-skills
Categories
Testing & QA, Rust
First seen
Jun 3, 2026

Questions

What does the rust-write-tests skill do?

It guides an agent to write Rust tests that guard a specific invariant rather than just proving code works. It applies a "What Could Break?" framework, five transformations from superficial to expert tests, a flake hunting protocol, and intent-based assertions.

How do I install the rust-write-tests skill?

Run npx -y skills add pproenca/dot-skills --skill rust-write-tests -y in your project. Once installed, the agent gets the Rust test writing guidance when you ask it to write tests or improve test quality.

How does rust-write-tests handle flaky tests?

It follows a flake hunting protocol: find the race window, replace timing with event-driven sync, make assertions order-independent, and stress-test the fix with cargo nextest. It also says never to use sleep as a synchronization primitive.

Which test naming style does rust-write-tests recommend?

It recommends the pattern subject_scenario_expected_outcome, so a failed test name reads as a bug description. Names such as sandbox_detection_requires_keywords show the style, while names like test_parse or it_works are flagged as anti-patterns.

More from pproenca/dot-skills

All 100

Similar to Rust Write Tests

More Testing & QA