Reputation: 18511
How do I mock a method that receives param - (Object... o)?
for instance I have the following method
Obj getByIds(String... ids);
I want something like
doReturn(...).when(myProxy).getByIds(any(String[].class));
or
doReturn(...).when(myProxy).getByIds(any(String.class));
But they both fail.
Upvotes: 1
Views: 78
Reputation: 3658
doReturn(...).when(myProxy).getByIds(Matchers.<String>anyVararg())
should work, see here
Upvotes: 2
Reputation: 2863
Try
doReturn(...).when(myProxy).getByIds((String) anyVarargs())
Upvotes: 0