
Rust Write Tests
This is Rust testing discipline codified. It walks you through the "What Could Break?" framework (invariants, edge cases, platform differences, refactor risks) before you write a single assertion, then shows five concrete transformations from weak tests to robust ones: whole-object comparisons instead of is_ok checks, sibling test files instead of inline modules, typed fixtures instead of JSON strings. The flake hunting protocol is pulled from 97+ real commits and teaches event-driven sync over sleeps. Test names follow the subject-scenario-outcome pattern so failures read like bug reports. If you're writing Rust tests that actually catch regressions instead of just proving the happy path works, this gives you the checklist and the refactoring patterns to get there.
- skills.sh installs
- 248
- GitHub stars
- 222
- last updated
- Aug 21, 2026
Install
$ npx -y skills add pproenca/dot-skills --skill rust-write-tests --agent claude-codeInstalls into .claude/skills of the current project.
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());
Sponsors
Details
- Repository
- github.com/pproenca/dot-skills
- Categories
- Testing & QA, Git & Pull Requests, Documentation, Code Review & Quality, Rust
- First seen
- Jun 3, 2026
More from pproenca/dot-skills
All 100- Rust Implement246
- Domain Architect242
- Graph Schema233
- Exec Plan232
- Framer Motion Best Practices187
- Rust124
- Zod7.2K
- Vitest7.2K
- React Hook Form3.1K
- Emilkowal Animations2.8K
- Nuqs2.4K
- Clean Architecture2K
- Typescript1.8K
- Code Simplifier1.6K
- Expo React Native Performance1.5K
- Nextjs1.2K
- Playwright1.2K
- Framer Motion1.2K
- Wxt Browser Extensions1.1K
- Msw897
- Tanstack Query858
- Clean Code857
- Terminal Ui853
- Ui Design827