Chapter 5. Parameterized tests

This chapter covers

  • Definition of parameterized tests
  • Using the where: block
  • Understanding data tables and data pipes
  • Writing custom data providers

The previous chapter presented all the Spock blocks that you can use in a unit test, except for one. I left out the where: block on purpose because it deserves a chapter of its own. The where: block is used for parameterized tests. Parameterized tests are unit tests that share the same test logic (for example, when the temperature goes up, the reactor must shut down), but need to run on different parameters (for example, with low temperature and then with high temperature) in order to account for all cases.

This chapter covers both some theory on when to use parameterized ...

Get Java Testing with Spock now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.