Part 2. Structuring Spock tests
This part contains the principal Spock knowledge. With the foundations out of the way, you’re ready to see the Spock syntax in all its glory, particularly the different parts of a Spock unit test and how they can be combined for various cases.
Chapter 4—the central chapter of the whole book—shows the individual parts of a Spock unit test (which are called blocks), their purpose, significance, and expected structure. This chapter also explains the lifecycle of a Spock test, the documentation annotations, and the facilities offered by Spock that affect the readability of a unit test. Make sure that you’ve mastered the topics of this chapter before moving on to the rest of the book.
Chapter 5 focuses on parameterized tests. Parameterized tests are unit tests that always test the same scenario with different input and output parameters. Depending on your application, you may have one or two parameterized tests (among your vanilla unit tests), or you may be overwhelmed with parameterized tests of multiple parameter combinations. Parameterized tests in Spock are a breath of fresh air compared to existing solutions, as Spock allows you to directly embed into source code the business description of input/output parameters.