B.3. Spock Genesis

Spock Genesis (https://github.com/Bijnagte/spock-genesis) is a meta data-generator library for parameterized Spock tests. I briefly mentioned it at the end of chapter 5. At its core, Spock Genesis can be used as a data source for Spock tests. The following listing is an example directly from Spock Genesis’ own samples.

Listing B.1. Creating test data with Spock Genesis

Spock Genesis can work as an abstraction over existing data generators, as it can also do the following:

  • Compose existing generators into new ones
  • Filter existing generators using predicates/closures
  • Randomize or order the output for other generators

You’ll ...

Get Java Testing with Spock now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.