skip method

void skip([
  1. String? message
])

Marks the current test as skipped.

If passed, message is emitted as a skip message.

Note that this does not mark the test as complete. That is, it sets the result to Result.skipped, but doesn't change the state.

Implementation

void skip([String? message]) {
  if (liveTest.state.shouldBeDone) {
    // Set the state explicitly so we don't get an extra error about the test
    // failing after being complete.
    _controller.setState(const State(Status.complete, Result.error));
    throw 'This test was marked as skipped after it had already completed.\n'
        'Make sure to use a matching library which informs the test runner\n'
        'of pending async work.';
  }

  if (message != null) _controller.message(Message.skip(message));
  // TODO: error if the test is already complete.
  _controller.setState(const State(Status.pending, Result.skipped));
}