Hypothesis-style property-based testing with shrinking for Rust
open sourceMIT OR Apache-2.0free
Proptest is a property testing framework for Rust in the QuickCheck family, inspired by Python's Hypothesis. It checks that properties of your code hold for arbitrary generated inputs, and when it finds a failure it shrinks the input to a minimal test case. Unlike QuickCheck, generation and shrinking are defined per value rather than per type, which makes strategies easier to compose. proptest-derive generates strategies for your own types, and its makers say it's close to feature-complete and mainly passively maintained.
Problems it solves
- test my Rust function against thousands of random inputs instead of hand-picked cases
- get the smallest input that breaks my Rust code when a test fails
- find edge cases my unit tests miss in a parser
Features
- property tests over automatically generated inputs
- automatic shrinking to a minimal failing case
- per-value generation and shrinking strategies that compose
- derive strategies for your own types with proptest-derive
Limitations
- Its makers describe it as close to feature-complete and mainly passively maintained.1
Alternatives
The same job
These do what Proptest does.
- quickcheck (Rust) Property-based testing for Rust with randomly generated inputs and shrinking
- Ephyra Rust property-based testing library where a coding agent writes and tunes the generators