So I'm trying to test a method methodUnderTest
which is something like this:
methodUnderTest{
//Other stuff that works nice
this.setterMethod(OtherClass.methodThatErrors);
}
So I'm trying to avoid that static method call methodThatErrors
.
What I'm doing so far:
ClassUnderTest spy = Mockito.spy(objectOfClassUnderTest);
Mockito.doNothing().when(spy).setterMethod(Mockito.any(OtherClass.class));
However this does not work, the method is still being called. I would've thought that it shouldn't call the argument method at all because I've written any
for the argument of setterMethod
. So how can I prevent this call using Mockito, not PowerMockito.
Aucun commentaire:
Enregistrer un commentaire