如何validation一个方法被调用两次mockito verify()

我想通过mockitovalidation来validation一个方法是否被调用两次或多次。 我使用validation,它像这样抱怨:

org.mockito.exceptions.verification.TooManyActualInvocations: Wanted 1 time: But was 2 times. Undesired invocation: 

当然,使用适当的VerificationMode:

 import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; verify(mockObject, atLeast(2)).someMethod("was called at least twice"); verify(mockObject, times(3)).someMethod("was called exactly three times");