Recently, I came across the need to generate test data for a protocol converter: a pair of functions converting one set of classes into another and back. To give you a bit more background, each set of classes represents the set of messages which can be exchanged between a service and a network client: one set which is used by the service internally, and the other set which is tied to the specific serialization protocol implementation (in this case Google protocol buffers). The protocol converter then boils down to some large pattern matches with quite boring code, hence the need for good and thorough verification.
In former times, I would have written down a smallish set of test data by hand, hoping to cover most cases. From that developed a technique where I explicitly convert some of these test instances into functions, leaving out one or two of the arguments and applying some randomly generated data to these. This approach does not scale, so inspired by the new Future.flow mechanism in the upcoming Akka 1.1 release (based on delimited continuations and monadic composition) I decided to try out something new: monadic test data generators.