March 2016
Intermediate to advanced
304 pages
8h 9m
English
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.

Data on the DB ...
Read now
Unlock full access