2.3. Groovy features useful to Spock tests
Now you have all the essential knowledge needed in order to write your own Spock assertions. The rest of this chapter continues with the theme of reducing unit test code size with the expressiveness provided by Groovy compared to Java. All the following techniques are optional, and you can still use normal Java code in your Spock tests if your organization needs a more gradual change. Each application is different, so it’s hard to predict all the ways that Groovy can help you with unit tests. The following selection is my personal preference.
2.3.1. Using map-based constructors
If there’s one feature of Groovy that I adore, it’s object creation. Most unit tests create new classes either as test data ...
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.