verify top-level property
Verify that a method on a mock object was called with the given arguments.
Call a method on a mock object within the call to verify
. For example:
cat.eatFood("chicken");
verify(cat.eatFood("fish"));
Mockito will fail the current test case if cat.eatFood
has not been called
with "fish"
. Optionally, call called
on the result, to verify that the
method was called a certain number of times. For example:
verify(cat.eatFood("fish")).called(2);
verify(cat.eatFood("fish")).called(greaterThan(3));
Note: When mockito verifies a method call, said call is then excluded from
further verifications. A single method call cannot be verified from multiple
calls to verify
, or verifyInOrder
. See more details in the FAQ.
Note: because of an unintended limitation, verify(...).called(0);
will
not work as expected. Please use verifyNever(...);
instead.
See also: verifyNever, verifyInOrder, verifyZeroInteractions, and verifyNoMoreInteractions.
Implementation
Verification get verify => _makeVerify(false);