I always thought Mockito works some some kind of proxy and things like that. But now I found out, that Mockito allows me to do something like
class A {
public String m1() {
return m2();
}
public String m2() {
return "Hello";
}
}
class TestA {
public testM1() {
A a = Mockito.spy(A.class);
when(a.m2()).thenReturn("Bye");
Assert.assertEquals(a.m1(), "Bye");
}
}
This wouldn't work with proxies. How does it do this? Could that technique be used to allow calling internal AOP-methods? (see Spring AOP not working for method call inside another method)