run method

Future<StepResult> run(
  1. World world,
  2. Reporter reporter,
  3. Duration defaultTimeout,
  4. Iterable parameters,
)
inherited

Implementation

Future<StepResult> run(
  TWorld world,
  Reporter reporter,
  Duration defaultTimeout,
  Iterable<dynamic> parameters,
) async {
  _ensureParameterCount(parameters.length, _expectParameterCount);
  late int elapsedMilliseconds;
  try {
    final timeout = _timeout ?? defaultTimeout;
    await Perf.measure(
      () async {
        _world = world;
        _reporter = reporter;
        _timeout = timeout;
        final result = await onRun(parameters).timeout(
          timeout,
        );

        return result;
      },
      (ms) => elapsedMilliseconds = ms,
    );
  } on GherkinTestFailure catch (tf) {
    return StepResult(
      elapsedMilliseconds,
      StepExecutionResult.fail,
      tf.message,
    );
  } on TimeoutException catch (te, st) {
    return ErroredStepResult(
      elapsedMilliseconds,
      StepExecutionResult.timeout,
      te,
      st,
    );
  } on Error catch (e, st) {
    return ErroredStepResult(
      elapsedMilliseconds,
      StepExecutionResult.error,
      Exception(e.toString()),
      st,
    );
  } catch (e, st) {
    return ErroredStepResult(
      elapsedMilliseconds,
      StepExecutionResult.error,
      e,
      st,
    );
  }

  return StepResult(elapsedMilliseconds, StepExecutionResult.pass);
}