talira

QuickCheck

Haskell library for property-based testing: check properties against randomly generated inputs

open sourceBSD-3-Clausefree

QuickCheck is a Haskell library for random testing of program properties. Instead of writing individual test cases, you state properties that functions should satisfy, and QuickCheck checks that they hold in a large number of randomly generated cases. It provides combinators for defining properties and test data generators and for observing the distribution of test data, plus a library for testing monadic code. It was written by Koen Claessen and is maintained by Nick Smallbone; the companion quickcheck-instances package adds instances for types in common Haskell packages, and it also runs on Hugs.

Problems it solves

  • my Haskell unit tests only cover the inputs I thought of
  • generate random test data for my Haskell functions instead of writing cases by hand
  • check that an encode and decode function round-trip for any input in Haskell

Features

  • properties written in Haskell with QuickCheck's combinators, tested on random inputs
  • combinators for custom test data generators
  • observing the distribution of test data
  • Test.QuickCheck.Monadic for testing monadic code
  • a Hugs-compatible build through its make-hugs script

Alternatives

The same job

These do what QuickCheck does.

  1. Hedgehog Property-based testing for Haskell with integrated shrinking
  2. fast-check Property-based testing for JavaScript and TypeScript

Compare QuickCheck with the top 3