called method
void
called(
- dynamic matcher
Assert that the number of calls matches matcher
.
Examples:
verify(mock.m()).called(1)
asserts thatm()
is called exactly once.verify(mock.m()).called(greaterThan(2))
asserts thatm()
is called more than two times.
To assert that a method was called zero times, use verifyNever.
Implementation
void called(dynamic matcher) {
if (!_testApiMismatchHasBeenChecked) {
// Only execute the check below once. `Invoker.current` may look like a
// cheap getter, but it involves Zones and casting.
_testApiMismatchHasBeenChecked = true;
}
expect(callCount, wrapMatcher(matcher),
reason: 'Unexpected number of calls');
}