← ClaudeAtlas

testing-reeflisted

Conventions and gotchas for writing tests in the reef Rust workspace — unit, integration, property, snapshot, benchmark, and fuzz. Use whenever adding or modifying a test in reef or test-support, or when the user asks "add a test for X", "how should I test Y", "why is this test flaky", "where does this test go", or anything about test fixtures, snapshots, proptest, or CI test failures. Also use when touching clock/time code (requires splitting `*_at(now, t)` helpers), or any code that mutates `cwd`/`HOME` (needs process-wide lock). Covers file-placement rules, the `test-support` fixture crate, insta filters, proptest strategy construction, and the specific pitfalls we've paid for in production — macOS tempdir symlinks, env-var sharing across parallel tests, and the HOME-redirect pattern for prefs-reading code.
Blushyes/reef · ★ 67 · Testing & QA · score 72
Install: claude install-skill Blushyes/reef
# Testing in the reef workspace A project-specific test playbook. Follow this when adding **any** test. The goal is that tests are deterministic across Linux/macOS CI and every dev's laptop, and that no test becomes that one flaky thing everyone reruns. ## Workspace layout (post-deplugin) Reef is a single-process binary — there is no plugin subsystem. The repo root IS the `reef` crate; the workspace exists only to hang the test-fixture helper off it: - **Root (`reef` crate)** — `src/` (app state, UI panels, git operations), `tests/` (integration), `benches/` (criterion). - **`crates/test-support`** — shared fixtures (`tempdir_repo`, `commit_file`, `write_file`, `HomeGuard`). - **`fuzz/`** — fuzz targets. Separate package, not in the workspace; run via `cargo +nightly fuzz run <target>`. ## Quick decision table | Scenario | Test type | Where it goes | |----------|-----------|---------------| | Pure function, no I/O | Unit test | `#[cfg(test)] mod tests` inline at bottom of the source file | | Uses `git2::Repository`, real fs | Integration test | `tests/<name>_integration.rs` | | Algorithmic invariant over random inputs | Property test | `tests/<name>_properties.rs` (uses `proptest`) | | Full UI rendered to terminal buffer | Snapshot | `tests/<name>_snapshots.rs` (uses `insta` + `ratatui::TestBackend`) | | Hot-path performance | Benchmark | `benches/<name>.rs` (uses `criterion`) | | Parser / deserializer robustness | Fuzz target | `fuzz/fuzz_targets/<name>.rs` | If you'r