B.8. Spock dbUnit extension
Chapter 7 shows how to use the Groovy SQL package to preload your database with test data needed for the Spock test. If you like this approach, you can take it a step further with the Spock dbUnit extension (https://github.com/janbols/spock-dbunit).
The extension is based on the well-known DbUnit library (http://dbunit.sourceforge.net/), initially developed for JUnit, that can initialize a database to a known state, reading data from XML files. The Spock dbUnit extension allows you to use Groovy code instead of XML files, as shown in the following listing.
Listing B.7. Fail all tests after three tries
Data on the DB ...