Testing Properties of Generic Functions
Report, 2006
Software testing is an important part of the software development process. Testing comes in many flavours: unit testing, property testing, regression testing, contract checking, etc. QuickCheck is probably one of the most advanced tools for testing properties of functional programs. It supports the definition of properties and random test-data generators in Haskell, and checks that a property passes the test cases. A datatype-generic function is parametrised by a type. Examples of generic functions are equality tests, maps and pretty printers. A generic function can be seen as a template algorithm that can be instantiated with (the structure of) a data type. Generic functions satisfy generic properties. This paper discusses testing properties of generic functions. It shows how generic properties can be formulated, and how QuickCheck can be used to test generic properties. Furthermore, it shows how to automatically generate QuickCheck generators using Generic Haskell.
Haskell
Generic Programming
Random Testing