Loading...
Loading...
Enforces TDD (Red-Green-Refactor) for Rust development. Auto-triggers on implementation, testing, refactoring, and bug fixing tasks. Provides Rust-idiomatic testing patterns with anyhow/thiserror, cfg(test), and Arrange-Act-Assert workflow.
npx skill4agent add rtk-ai/rtk rtk-tdd1. Write test in #[cfg(test)] mod tests of the SAME file
2. cargo test MODULE::tests::test_name -- must FAIL (red)
3. Implement the minimum in the function
4. cargo test MODULE::tests::test_name -- must PASS (green)
5. Refactor if needed, re-run cargo test (still green)
6. cargo fmt && cargo clippy --all-targets && cargo test (final gate)| Pattern | Usage | When |
|---|---|---|
| Arrange-Act-Assert | Base structure for every test | Always |
| Direct comparison / booleans | Deterministic values |
| Error path testing | Invalid inputs |
| Tests with | Fallible functions |
| Expected panic | Invariants, preconditions |
| File/I/O tests | Filesystem-dependent code |
| Code Type | Test Pattern | Example |
|---|---|---|
| Pure function (str -> str) | Input literal -> assert output | |
| Parsing/filtering | Raw string -> filter -> contains/not-contains | |
| Validation/security | Boundary inputs -> assert bool | |
| Error handling | Bad input -> | |
| Struct/enum roundtrip | Construct -> serialize -> deserialize -> eq | |
test_{function}_{scenario}
test_{function}_{input_type}test_truncate_edge_casetest_parse_invalid_inputtest_filter_empty_stringCommand::new()std::process::exit()Resultcargo fmt --all --check
cargo clippy --all-targets
cargo test#[allow(...)]