Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What _ (underscore) means in Spock tests?

In one of the Spock tests I see a strange condition in then block:

0 * someInstance._

What does it mean?

like image 345
Xelian Avatar asked Dec 10 '14 07:12

Xelian


1 Answers

_ is a wildcard, any object. See here to find how its exactly implemented and here for the docs. _ it's used for instance to check invocation of a method which argument does not matter, then it looks like:

1 * obj.method(1, _)

In this particular case it's checked if method method on instance obj was invoked exactly once with 1 as a first argument and anything as a second.

like image 69
Opal Avatar answered Sep 28 '22 02:09

Opal