Part 3. Spock in the Enterprise

 

The last part of the book examines Spock in the context of a large enterprise application. Enterprise applications sometimes have unique requirements in terms of their complexity and the breadth of features they must offer. Spock is ready for the Enterprise, as it comes with several features that come in handy in large and complicated unit tests.

Chapter 7 examines the use of Spock in the full testing lifecycle of an enterprise application. Spock can cover trivial plain unit tests, larger integration tests, and even functional tests. Several examples (mostly with Spring) show that Spock allows you to reuse your favorite Java testing tools with zero additional effort. At the same time, Spock can employ Groovy testing libraries, which may be more appropriate in your specific application.

Chapter 8 builds upon the knowledge of all previous chapters by describing corner cases that need special attention in your Enterprise Spock tests. It describes several additional Spock annotations that enable/disable the running of a test in a static or dynamic way and then shows you how to refactor large Spock tests with helper methods. The chapter finishes with a demonstration of Spock spies, a feature that I explicitly advise you not to use.