I am using Mockito 1.8.0, so I do not AnyVararg. Upgrading to a later version of Mockito is not on my team’s maps right now. So please bear with me
What the class looks like:
public abstract class Parent {
public void someMethod(String a, String b)
{
}
public void foo(String a, String... b)
{
}
}
public class Child extends Parent{
public void bar() {
someMethod(a,b);
foo(a,b,c);
methodToFailUsingSpy();
}
}
Unit tests
@Test
public void someTest() {
private spyOfChild =
doReturn("Something")).when(spyOfChild).methodToFailUsingSpy();
spyOfChild.bar();
}
The problem is
When the spy sees someMethod(), he calls the real method in the abstract class. But when he sees foo(), he tries to find the corresponding encoded method. Ie control goes into Mockito MethodInterceptorFilter, since it cannot find the layout, it throws java.lang.reflect.InvocationTargetException.
, foo() . , , someMethod(). - , - ?