rust-unit-tests
Installation
SKILL.md
Rust Unit Tests in warp
Scope
- This skill focuses on crate-level unit tests.
- Favor incremental, well-scoped tests that exercise a single function or behavior per case.
- For how to structure and run tests, read on. For whether a change needs a test and at what level, start with "What to unit test".
What to unit test
Default to a unit test when the logic is deterministic and reachable without booting the app:
- Parsing, encoding, escaping, and any pure data transformation.
- Domain logic and state machines (block lifecycle, selection, ranges, diffing).
- Boundary and edge cases: empty input, single element, off-by-one at range ends, min/max, invalid UTF-8, zero-width and wide grapheme clusters.
- Error paths and fallbacks, not just the happy path.
- Bug fixes, where the bug is reachable at this level. A reproducible bug usually means a case was missing from the suite, so add the failing test first and then fix it. Not every bug is unit-testable — a rendering artifact, a PTY timing race, or a crash that needs a real window will not reduce to one. Cover those at the level where they actually reproduce, and don't reshape the code just to force a unit test.
Prefer unit tests for anything that fits: they are fast, deterministic, and point straight at the failure.