Let's say my class is Foo with a recursive method bar which calls a service like below
public class Foo
{
private DataService service;
public void perform(int count, final SomeObject obj)
{
if(count > 0)
{
service.refresh(obj);
count = count- 1;
perform(count, obj)
}
}
}
Now I want to verify number of times refresh method gets called for differnt input, something like this
@Test
def "test method"()
{
given:
def obj = Mock(SomeObject)
expect:
foo.perform(refreshRequests, inputObj)
where:
refreshRequests | inputObj |
1 | obj | 1 * service.refresh(obj)
2 | obj | 2 * service.refresh(obj)
}
Is there a way to achieve something like this? Thanks in advance!