- Notifications
You must be signed in to change notification settings - Fork108
hedgehogqa/haskell-hedgehog
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation

Hedgehog automatically generates a comprehensive array of test cases, exercising your software in ways human testers would never imagine.
Generate hundreds of test cases automatically, exposing even the most insidious of corner cases. Failures are automatically simplified, giving developers coherent, intelligible error messages.
- Integrated shrinking, shrinks obey invariants by construction.
- Abstract state machine testing.
- Generators allow monadic effects.
- Range combinators for full control over the scope of generated numbers and collections.
- Equality and roundtrip assertions show a diff instead of the two inequal values.
- Template Haskell test runner which executes properties concurrently.
The main module,Hedgehog, includes almosteverything you need to get started writing property tests with Hedgehog.
It is designed to be used alongsideHedgehog.GenandHedgehog.Range which should be importedqualified. You also need to enable Template Haskell so the Hedgehog testrunner can find your properties.
{-#LANGUAGE TemplateHaskell #-}importHedgehogimportqualifiedHedgehog.GenasGenimportqualifiedHedgehog.RangeasRange
Once you have your imports set up, you can write a simple property:
prop_reverse::Propertyprop_reverse= property$do xs<- forAll$Gen.list (Range.linear0100)Gen.alphareverse (reverse xs)=== xs
And add the Template Haskell splice which will discover your properties:
tests::IOBooltests= checkParallel$$(discover)
If you prefer to avoid macros, you can specify the group of propertiesto run manually instead:
{-#LANGUAGE OverloadedStrings #-}tests::IOBooltests= checkParallel$Group"Test.Example" [ ("prop_reverse", prop_reverse) ]
You can then load the module in GHCi, and run it:
λ tests━━━ Test.Example ━━━ ✓ prop_reverse passed 100 tests.
As we come to the end of our guide to haskell-hedgehog, we'd like to take a moment to remember and honor one of its key contributors, our dear friend, author and co-founder, Jacob Stanley.
Jacob's passion for Haskell and his commitment to creating high-quality, reliable software was truly inspiring. His work has shaped haskell-hedgehog in countless ways, and without him, it wouldn't be the project it is today.
Jacob passed away unexpectedly on April 9th. His absence is deeply felt, but his impact on this project, and on all of us who had the privilege to work with him, remains. We continue to maintain and develop haskell-hedgehog in his memory and in honor of his dedication to excellence in programming.
As you explore haskell-hedgehog, and possibly contribute to its ongoing development, we invite you to join us in remembering Jacob Stanley — a tremendous developer, collaborator, and friend.
About
Release with confidence, state-of-the-art property testing for Haskell.
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.