← ClaudeAtlas

rust-tddlisted

Test-first workflow for Rust — a rigid red-green-refactor-lint cycle with cargo and cargo-nextest for new features, bug fixes, and refactors. Covers running one test at a time, test placement from unit to integration to end-to-end, hand-written fakes instead of mocking crates, a fault-injection queue for error paths, async test structure with tokio, golden-contract tests with a safe bless procedure, and a subagent split that keeps test design free of implementation bias. Use when you start a behavior change in Rust, reproduce a reported bug, refactor code that must keep its behavior, or review whether a test suite was really written test-first.
po4yka/rust-skills · ★ 0 · Testing & QA · score 75
Install: claude install-skill po4yka/rust-skills
# Rust TDD ## Purpose This skill is **rigid**. Follow every step exactly. Do not skip RED. Do not write implementation before a failing test exists. The value of TDD is not the test file. The value is that the test failed first, for the reason you predicted. A test written after the implementation only proves that the code does what the code does. ## The cycle Repeat this cycle for every behavior change: 1. **RED** — Write exactly one failing test. Run it. Confirm that it fails, and that it fails for the expected reason. A compile error is not a valid RED. Make the test compile, then let the assertion fail. 2. **GREEN** — Write the minimum implementation that makes the test pass. Run the test again. Do not add code that no test requires. 3. **REFACTOR** — Clean up the test and the implementation. Run the crate tests to confirm that nothing broke. 4. **LINT** — Run the format and lint gate before you call the cycle complete. ```bash cargo fmt --all -- --check cargo clippy --workspace --all-targets --all-features --locked -- -D warnings ``` `--all-targets` includes tests, benches, and examples. The lint gate applies to test code too. See the `rust-lints` skill for the lint set and for allow-with-reason policy. Never batch multiple behaviors into one cycle. One test, one behavior, one cycle. ### RED is a prediction, not a formality Before you run the failing test, write down the expected failure in one sentence: which assertion fails, and with which value.