Issue
If we have this code:
@Test
public void test1(){
Interface1 i1 = mock(Interface1.class)
method1(); // This method calls i1.mockedmethod()
verify(i1, times(1)).mockedmethod();
method1();
verify(i1, times(2)).mockedmethod();
}
I know that it will pass the first verify, but I'm in doubt with the second one. Does verify method counts all the times that the method has been called or it only counts it since the last verify?
Solution
Once created, mock will remember all interactions. Then you can selectively verify whatever interaction you are interested in.
It means that your mock counts each time you call the method you want and it does not reset when you call verify
.
If you want further information about that, read this ( this is where I have found these information):
http://site.mockito.org/mockito/docs/current/org/mockito/Mockito.html
Answered By - Shondeslitch
Answer Checked By - Terry (JavaFixing Volunteer)