mardi 22 décembre 2015

verify on mockito spy calls implementation

Let's assume below test

public void someTest() throws Exception {
   Foo foo = spy(new Foo());
   foo.someMethod();
   verify(foo).methodToBeVerified();
}

When the test executes it calls real implementation of foo.methodToBeVerified(). Which is not my expectation. I would like the test (or mockito) to verify whether that particular method has been called or not and I do not want it to execute. Is it possible to do that using spy?

Aucun commentaire:

Enregistrer un commentaire