O'Reilly logo

Java Testing with Spock by Konstantinos Kapelonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Writing unit tests with Spock

This chapter covers

  • Working with Spock blocks
  • Understanding the lifecycle of a test
  • Improving readability of Spock tests
  • Using reusable JUnit features

All the Spock tests you’ve seen so far have been presented to you as a finished unit test, with no explanation of how to reach that particular code structure. You’re probably eager to create your own Spock tests from scratch. In this chapter, you’ll see all the building blocks that compose a Spock test and how they fit together (various combinations are possible).

You’ll also learn about the lifecycle of a Spock test and how to interact with its various phases. Finally, you’ll see some tricks for handling lengthy Spock tests and making them more ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required