Indicate that callback
is expected to be called count
number of times
(by default 1).
The test framework will wait for the callback to run the count
times
before it considers the current test to be complete. callback
may take up
to six optional or required positional arguments; named arguments are not
supported.
max
can be used to specify an upper bound on the number of calls; if this
is exceeded the test will fail. If max
is 0
(the default), the callback
is expected to be called exactly count
times. If max
is -1
, the
callback is allowed to be called any number of times greater than count
.
Both id
and reason
are optional and provide extra information about the
callback when debugging. id
should be the name of the callback, while
reason
should be the reason the callback is expected to be called.
Source
Function expectAsync(Function callback, {int count: 1, int max: 0, String id, String reason}) { if (Invoker.current == null) { throw new StateError("expectAsync() may only be called within a test."); } return new _ExpectedFunction(callback, count, max, id: id, reason: reason) .func; }