Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove constraints on the number of arguments when mocking with Spock?

Is there a way to accept any number of arguments when mocking a method?

For instance if I want to mock those 2 methods:

foo(String s);
foo(String s, int i);

For now, in my test I do:

myMockedClass.foo(_) >> x
myMockedClass.foo(_, _) >> x

Is there a way to mock both at once? Something like:

myMockedClass.foo(*) >> x

(this doesn't work)

like image 733
Jules Olléon Avatar asked Jan 12 '12 03:01

Jules Olléon


1 Answers

This feature is planned, but doesn't exist yet. The proposed syntax is foo.bar(*_).

like image 117
Peter Niederwieser Avatar answered Oct 04 '22 02:10

Peter Niederwieser