start static method

TestCaseMonitor start(
  1. FutureOr<void> body()
)

Start body as a test case and return a TestCaseMonitor with the status and result.

The state will start as State.pending if queried synchronously, but it will switch to State.running. After onDone completes the state will be one of State.passed, State.skipped, or State.failed.

Note that a test can change state from State.passed to State.failed if the test surfaces an unawaited asynchronous error.

late void Function() completeWork;
final monitor = TestCaseMonitor.start(() {
  final outstandingWork = TestHandle.current.markPending();
  completeWork = outstandingWork.complete;
});
await pumpEventQueue();
assert(monitor.state == State.running);
completeWork();
await monitor.onDone;
assert(monitor.state == State.passed);

Implementation

static TestCaseMonitor start(FutureOr<void> Function() body) =>
    TestCaseMonitor._(body).._start();