Verification · Testing
Property-based tests
Generates inputs and checks invariants that must hold for all of them, then shrinks failures to a minimal case.
Sub-techniques
-
Round-trip properties
V1021.001decode(encode(x)) == x for serializers and parsers.
-
Model-based properties
V1021.002Compare the implementation against a simple reference model.
-
Stateful testing
V1021.003Generate sequences of operations and check invariants after each.
How to build it
- Start with round-trip and idempotence properties; they need no oracle.
- Persist the failure database so found cases are replayed.
- Promote shrunk failures to example tests.
Signals in a repository
- @given decorators, fc.assert or proptest! macros in tests.
- .hypothesis/ in .gitignore.