called method

void called(
  1. dynamic matcher
)

Assert that the number of calls matches matcher.

Examples:

  • verify(mock.m()).called(1) asserts that m() is called exactly once.
  • verify(mock.m()).called(greaterThan(2)) asserts that m() is called more than two times.

To assert that a method was called zero times, use verifyNever.

Implementation

void called(dynamic matcher) {
  expect(
    callCount,
    wrapMatcher(matcher),
    reason: 'Unexpected number of calls',
  );
}