1.3. Spock: the groovier testing framework

When I first came upon Spock, I thought that it would be the JUnit alternative to the Groovy programming language. After all, once a programming language reaches a critical mass, somebody ports the standard testing model, known as xUnit (https://en.wikipedia.org/wiki/XUnit), to the respective runtime environment. xUnit frameworks already exist for all popular programming languages.

But Spock is not the xUnit of Groovy! It resembles higher-level testing frameworks, such as RSpec and Cucumber (https://github.com/cucumber/cucumber-jvm), that follow the concepts of BDD, instead of the basic setup-stimulate-assert style of xUnit. BDD attempts (among other things) to create a one-to-one mapping between business ...

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.