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
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.rsfiles, typed factory fixtures, andBTreeMapfor 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 -yInstalls 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:
- What invariant does this code maintain? (e.g., "deserialized config always has a default profile")
- What edge case would violate it? (e.g., "empty TOML table, missing key, extra unknown key")
- What platform difference could surface? (e.g., "path separators, case sensitivity, symlink behavior")
- 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- Rails Application Ui Blocks261
- Rust Implement260
- Domain Architect254
- Exec Plan243
- Graph Schema243
- Framer Motion Best Practices187
- Rust124
- Vitest8.4K
- Zod7.5K
- React Hook Form3.2K
- Emilkowal Animations2.8K
- Nuqs2.5K
- Clean Architecture2.1K
- Typescript1.8K
- Code Simplifier1.7K
- Expo React Native Performance1.5K
- Nextjs1.2K
- Framer Motion1.2K
- Playwright1.2K
- Wxt Browser Extensions1.1K
- Tanstack Query1.1K
- Msw926
- Clean Code879
- Terminal Ui879
Similar to Rust Write Tests
More Testing & QArust-best-practicesapollographql/skills24.9K installsIdiomatic Rust guidance covering ownership, error handling, performance, linting, testing, and documentation, drawn from Apollo's handbook.
rust-implementpproenca/dot-skills260 installsMulti-pass Rust workflow that designs types first, implements, simplifies, then runs an automated lint against the code.
rails-testingpproenca/dot-skills313 installsComprehensive RSpec and Rails testing guide covering test design, factories, system tests, and suite performance.
rtk-tddrtk-ai/rtk2.4K installsEnforces Red-Green-Refactor TDD for Rust, with idiomatic test patterns and a strict pre-commit gate.
rust-skillsleonardomso/rust-skills8K installsComprehensive Rust coding guidelines with 265 rules across 26 categories for writing and reviewing code.