How to remove restrictions on the number of arguments when taunting Spock?

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

For example, if I want to mock these two methods:

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

Bye, in my test:

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

Is there a way to fool both at once? Sort of:

 myMockedClass.foo(*) >> x 

(this does not work)

+4
source share
1 answer

This feature is planned, but does not exist yet. Suggested syntax foo.bar(*_) .

+3
source

Source: https://habr.com/ru/post/1390569/


All Articles