Property-based testing for Haskell with integrated shrinking
open sourceBSD-3-Clausefree
Hedgehog is a property-based testing library for Haskell: properties describe what must hold, and Hedgehog generates hundreds of test cases to check them. When a case fails, integrated shrinking simplifies it to a small counterexample, and shrinks obey the generators' invariants by construction. It also does abstract state machine testing, its generators may run monadic effects, Range combinators bound generated numbers and collections, and failed equality and round-trip assertions show a diff. A Template Haskell runner discovers properties and runs them concurrently.
Problems it solves
- my Haskell unit tests only cover the cases I thought of
- a property test found a bug but the failing input is huge and hard to read
- test a stateful Haskell API by generating random sequences of operations
Features
- integrated shrinking that respects generator invariants
- abstract state machine testing
- generators with monadic effects
- Range combinators for generated numbers and collections
- diffs on failed equality and round-trip assertions
- Template Haskell runner that runs properties concurrently
Limitations
- Finding properties automatically needs Template Haskell; without it, properties are listed by hand.1
Alternatives
The same job
These do what Hedgehog does.
- QuickCheck Haskell library for property-based testing: check properties against randomly generated inputs
