There is the following code. It checks the number of calls to the oneFunc function.

 one = spy(one); one.oneFunc(" "); verify(one, times(1)).oneFunc(anyString()); one.oneFunc(" "); verify(one, times(2)).oneFunc(anyString()); 

Is it possible to somehow reset the number of calls so that calls are counted from the last zeroing? Those. something like this:

 one = spy(one); one.oneFunc(" "); verify(one, times(1)).oneFunc(anyString()); //Строка, обнуляющая количество one.oneFunc(" "); verify(one, times(1)).oneFunc(anyString()); 
  • I could be wrong, but you tried to create a new spy? - Vartlok
  • In my case, there is no way to create a new spy due to the structure of the test. I just need to reset the counter. - Andrey Kuruljov
  • one
    Then you have the wrong test) stackoverflow.com/questions/15090317/resetting-mockito-spy - Vartlok
  • @Vartlok and in this it is wrong? And yes, thanks for the link, Mockito.reset(one); - this is what I needed. - Andrei Kurulyov
  • In that the test should test one, the selected part, the same unit tests, and not integration tests. And if you need to reset the mock, then the test is too big and it should be broken. The link about it is said. - Vartlok

0