This document describes the testing infrastructure for pattern-rs, including property-based testing, equivalence checking, snapshot testing, benchmarks, and test helpers.
The testing infrastructure provides comprehensive tools for ensuring correctness and behavioral equivalence with the gram-hs reference implementation.
Property-based testing generates random test inputs automatically and validates properties that should always hold true.
Usage: See specs/003-test-infrastructure/quickstart.md for examples.
Utilities for comparing outputs from pattern-rs and gram-hs implementations to ensure behavioral equivalence.
Usage:
- See
crates/pattern-core/src/test_utils/equivalence.rsfor API documentation - See gram-hs CLI Testing Guide for using the
gram-hsCLI tool with--value-only,--deterministic, and--canonicalflags for reliable comparison
Snapshot testing captures outputs and detects changes to catch regressions.
Usage: See crates/pattern-core/tests/snapshot/README.md for workflow.
Performance benchmarks for tracking performance over time and detecting regressions.
Usage: See benches/README.md for details.
Utilities for pattern comparison and validation that reduce boilerplate in tests.
Usage: See crates/pattern-core/src/test_utils/helpers.rs for API documentation.
A new developer can write a property test within 15 minutes:
- Add test dependencies to your crate's
Cargo.toml - Create a test file in
tests/property/ - Write a property test using
proptest!macro - Run with
cargo test
See specs/003-test-infrastructure/quickstart.md for detailed examples.
All testing infrastructure integrates with the Cargo workspace structure and works across all crates.