Testing and benchmarking
The libraries in this subsection are as follows:
QuickCheck: Property-checking with automatic test-case generation
doctest: Writing tests and expected results directly in haddock comments
HSpec, HUnit, tasty: Traditional unit-testing libraries
criterion: Benchmarking time usage
weigh: Benchmark allocation
There are two testing libraries that are rather novel in Haskell: QuickCheck
and doctest
. QuickCheck
lets the programmer just state a property for a function, leaving it to the library to try proving it false.
Doctest
builds on the ingenious idea of combining test cases with docstrings
. It's especially useful in libraries, because it gives users reading the documentation always up-to-date information about properties and use of functions that have tests annotated in their documentation.
More traditional testing frameworks such as HSpec
, HUnit
, tasty
and time-benchmarking
library criterion are discussed in detail in Chapter 4, The Devil's in the Detail.
A newcomer library...