pproenca avatar

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-code

Installs 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:

  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());

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
1existential-birds avatarpytest-code-reviewexistential-birds/beagleReviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usag232skills.sh installs
2el-feo avatarcucumber-gherkinel-feo/ai-contextBDD testing with Cucumber and Gherkin for Ruby and Rails applications. Use when writing feature files (.feature), step definitions, hooks, or implementing Behav215skills.sh installs
3yonatangross avatarverifyyonatangross/orchestkitGrade work that already exists and decide whether it can merge. Runs the project's current unit, integration, and E2E suites plus security scanning and type che210skills.sh installs
4hieutrtr avatarreact-frontend-experthieutrtr/ai1-skillsReact/TypeScript frontend implementation patterns. Use during the implementation phase when creating or modifying React components, custom hooks, pages, data fe206skills.sh installs
5hoodini avatarbunhoodini/ai-agents-skillsBuild fast applications with Bun JavaScript runtime. Use when creating Bun projects, using Bun APIs, bundling, testing, or optimizing Node.js alternatives. Trig191skills.sh installs
6daffy0208 avatarusability-testerdaffy0208/ai-dev-standardsConduct usability tests and identify UX issues through systematic observation. Use when testing user flows, validating designs, identifying friction points, or 188skills.sh installs