11

I have the following parameters for the same test:

  a  |  b  |  c
  1  |  2  |  3
 11  | 22  | 33

Spock provides the @Unroll annotation for tests similar to this (with this set of parameters you can run to same tests with the vectors [1, 2, 3] and [11, 22, 33]).

However, I need to run the same test for all the possible permutations (e.g [1, 2, 3], [1, 2, 33], [11, 2, 33] and etc, all the 8 combinations). How can I achieve it?

Thanks for any thoughts!

Dmitry Senkovich
  • 5,521
  • 8
  • 37
  • 74

1 Answers1

26

You need

where:
[a, b, c] << [[1, 11], [2, 12], [3, 13]].combinations()
tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • Super! I have never seen this feature. – Dmytro Maslenko Aug 10 '17 at 21:57
  • This looks really great! FWIW however: I don't think this would work well when the test expectation is particular to the individual permutations - those expectations need to be associated individually with each permutation... which I think would unfortunately defeat the whole intent of this sort of syntax. Note that the table in the Question here does not include an expectation column (with non-uniform booleans across all rows ;). But this Answer is still great for tests where the expectation is indeed all the same! – cellepo Feb 11 '21 at 22:29