Package org.mockito.verification
Interface VerificationWithTimeout
-
- All Superinterfaces:
VerificationMode
- All Known Implementing Classes:
Timeout
public interface VerificationWithTimeout extends VerificationMode
VerificationWithTimeout is aVerificationMode
that allows combining existing verification modes with 'timeout'. E.g:
This is similar toverify(mock, timeout(100).times(5)).foo(); verify(mock, timeout(200).atLeastOnce()).baz();
after()
except this assertion will immediately pass if it becomes true at any point, whereas after() will wait the full period. Assertions which are consistently expected to be initially true and potentially become false are deprecated below, and after() should be used instead.See examples in javadoc for
Mockito.verify(Object, VerificationMode)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description VerificationMode
atLeast(int minNumberOfInvocations)
Allows at-least-x verification within given timeout.VerificationMode
atLeastOnce()
Allows at-least-once verification within given timeout.VerificationMode
only()
Allows checking if given method was the only one invoked.VerificationMode
times(int wantedNumberOfInvocations)
Allows verifying exact number of invocations within given timeout-
Methods inherited from interface org.mockito.verification.VerificationMode
description, verify
-
-
-
-
Method Detail
-
times
VerificationMode times(int wantedNumberOfInvocations)
Allows verifying exact number of invocations within given timeout
See examples in javadoc forverify(mock, timeout(100).times(2)).someMethod("some arg");
Mockito
class- Parameters:
wantedNumberOfInvocations
- wanted number of invocations- Returns:
- verification mode
-
atLeastOnce
VerificationMode atLeastOnce()
Allows at-least-once verification within given timeout. E.g:
Alias to atLeast(1)verify(mock, timeout(100).atLeastOnce()).someMethod("some arg");
See examples in javadoc for
Mockito
class- Returns:
- verification mode
-
atLeast
VerificationMode atLeast(int minNumberOfInvocations)
Allows at-least-x verification within given timeout. E.g:
See examples in javadoc forverify(mock, timeout(100).atLeast(3)).someMethod("some arg");
Mockito
class- Parameters:
minNumberOfInvocations
- minimum number of invocations- Returns:
- verification mode
-
only
VerificationMode only()
Allows checking if given method was the only one invoked. E.g:verify(mock, only()).someMethod(); //above is a shorthand for following 2 lines of code: verify(mock).someMethod(); verifyNoMoreInteractions(mock);
See also
Mockito.verifyNoMoreInteractions(Object...)
See examples in javadoc for
Mockito
class- Returns:
- verification mode
-
-