5.3. Using data pipes for calculating input/output parameters

Data tables should be your bread and butter when writing Spock parameterized tests. They shine when all input and output parameters are known in advance and thus can be embedded directly in the source code.

But sometimes the test parameters are computed on the spot or come from an external source (typically a file, as you’ll see later in this chapter). For those cases, using data pipes is a better option. Data pipes are a lower-level construct of Spock parameterized tests that can be used when you want to dynamically create/read test parameters.[8]

8

Data tables can be seen as an abstraction over data pipes.

As a first example, let’s rewrite the first data table code of listing ...

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.