vendredi 21 août 2015

PowerMockito partial mock for static public method using spy

I am trying to partial mock Static class which call public static method on the same class has structure like below :

ClazzUnderTest {
methodUnderTest(){
call publicMethod();
}
publicMethod(){
}
privateMethod(){
}
}
PowerMockito.spy(ClazzUnderTest.class);
doReturn(objMock).when(ClazzUnderTest.class, "publicMethod");

It seems partial mocking using spy not working for public static method. Bcoz for private method its working as per expectation , getting error

Actually, there were zero interactions with this mock.
    at org.powermock.api.mockito.internal.invocation.MockitoMethodInvocationControl.performIntercept(MockitoMethodInvocationControl.java:262)

Aucun commentaire:

Enregistrer un commentaire