Skip to content

Generative Testing

stuarthalloway edited this page Feb 20, 2013 · 2 revisions


Traditional automated testing approches combine input generation, execution, output capture, and validation inside the bodies of single functions. Generative testing approaches gain expressive power by isolating these steps.

With generative testing:

  • a generator is a declarative description of possible inputs to a function
  • execution is up to your program
  • outputs are data, and can be captured for future study
  • validators are programs that have access to the generators, the program, and the outputs

There are a number of benefits to this approach:

  • once test data generation is separate, it is immediately obvious that such data generation should be statistical, not merely a few hand-picked cases
  • validators can be reused in a variety of
  • it becomes easier to identify and develop declarative, logic-based validations, rather than imperative ones
  • the various phases can be decoupled and run at different times

This talk introduces test data generation and generative testing, using for its examples the data.generators and test.generative libraries developed by the author.


You can’t perform that action at this time.