Test Audit & Rewrite
Interactive workflow for auditing and rewriting project test suites.
Principles
- •Test all code, but only our code—not the library or language
- •Prefer property-based tests for serialization, parsing, and validation patterns
- •Use snapshot tests for multi-line string outputs
- •Write only necessary tests—no redundancy
- •Each test should be small and focused
Workflow
Phase 1: Discovery
- •Identify test framework and existing patterns (snapshot lib, PBT lib, assert style)
- •Map source modules to their test files
- •Note coverage gaps and redundant tests
Present findings and discuss the audit scope before proceeding.
Phase 2: Planning
For each module, propose:
- •Tests to keep (with reason)
- •Tests to consolidate or remove
- •New tests needed
- •PBT opportunities (encode/decode pairs, validators, parsers)
- •Snapshot opportunities (structured output, error messages)
Discuss the plan interactively—adjust based on feedback.
Phase 3: Execution
Work module-by-module:
- •Confirm the plan for current module
- •Rewrite tests
- •Run tests to verify
- •Move to next module
Test Selection Heuristics
Keep tests that:
- •Cover distinct behavior or edge case
- •Document important invariants
- •Catch real bugs that occurred
Consolidate tests that:
- •Test the same code path with trivial variations
- •Can be replaced by a single parameterized/table-driven test
- •Can be replaced by a property-based test
Remove tests that:
- •Test library/framework behavior
- •Duplicate other tests
- •Test implementation details that may change
Language-Specific Patterns
See references for language-specific testing conventions:
- •references/gleam.md - qcheck, birdie, assert style
- •references/rust.md - proptest, insta, mod test