I have a test class (based on TestNG) where I use Mockito.verify for a spy object.
It works:
public class Program { @Spy private TestObject testObject; @Test public void test1() { testObject.makeSth(); verify(testObject, only()).someMethodNeedToBeChecked(); } }
But here:
public class Program { @Spy private TestObject testObject; @Test public void test1() { testObject.makeSth(); verify(testObject, only()).someMethodNeedToBeChecked(); } @Test public void test2() {
I get a Mokito exception, I have more than one call to someMethodNeedToBeChecked . Of course, I tried to add Mockito.reset(testObject) , but that didn't help me at all.
How can I reset a spy object if I need to test the same method in several tests?
Alexander Bezrodniy
source share