It is generally agreed that formulating careful specifications of software is
a good idea, whether before or after the software is written. Specifications
improve software design, by revealing unclear behaviour or complicated
cases. Specifications guide programming, by offering an objective
criterion for whether a program is right or wrong. Specifications assist
reuse, by documenting exactly what software is supposed to do.
However, specifications are used much less in practice than one might
expect. Our goal in developing QuickCheck is to add value to
specifications, by offering a short-term payoff for their use.
- QuickCheck encourages you to formulate precise, formal specifications, in
Haskell, a language you already know. Like other formal specifications,
QuickCheck properties have an unambiguous and clear meaning.
- QuickCheck checks your program against the specification, by
testing. Although this cannot guarantee that the program and
specification are consistent, it greatly reduces the risk that they are
not. It is easy to recheck consistency after every change to a module.
- QuickCheck specifications document how you tested your program;
other programmers using your code can see which properties have been tested,
and which have not.
- QuickCheck reduces the time spent on testing, by generating many test
cases automatically. This saving can be set against the time spent on
formulating the specification in the first place.