runScenario method
void
runScenario({})
Implementation
@protected
void runScenario({
required String name,
required Iterable<String>? tags,
required List<StepFn> steps,
required String path,
String? description,
Future<void> Function()? onBefore,
Future<void> Function()? onAfter,
}) {
if (_evaluateTagFilterExpression(configuration.tagExpression, tags)) {
testWidgets(
name,
(WidgetTester tester) async {
if (onBefore != null) {
await onBefore();
}
bool failed = false;
final debugInformation = RunnableDebugInformation(path, 0, name);
final scenarioTags = (tags ?? const Iterable<Tag>.empty()).map(
(t) => Tag(t.toString(), 0),
);
final dependencies = await createTestDependencies(
configuration,
tester,
);
try {
await hook.onBeforeScenario(
configuration,
name,
scenarioTags,
);
await startApp(
tester,
dependencies.world,
);
await hook.onAfterScenarioWorldCreated(
dependencies.world,
name,
scenarioTags,
);
await reporter.scenario.onStarted.invoke(
ScenarioMessage(
name: name,
description: description,
context: debugInformation,
tags: scenarioTags.toList(),
),
);
var hasToSkip = false;
for (int i = 0; i < steps.length; i++) {
try {
final result = await steps[i](dependencies, hasToSkip);
if (_isNegativeResult(result.result)) {
failed = true;
hasToSkip = true;
}
} catch (err, st) {
failed = true;
hasToSkip = true;
await reporter.onException(err, st);
}
}
} finally {
await reporter.scenario.onFinished.invoke(
ScenarioMessage(
name: name,
description: description,
context: debugInformation,
hasPassed: !failed,
),
);
await hook.onAfterScenario(
configuration,
name,
scenarioTags,
passed: !failed,
);
if (onAfter != null) {
await onAfter();
}
// need to pump so app can finalise
await _appLifecyclePhasePumper(
AppLifecyclePhase.finalisation,
tester,
);
await cleanUpScenarioRun(dependencies);
}
},
timeout: scenarioExecutionTimeout,
semanticsEnabled: configuration.semanticsEnabled,
);
} else {
reporter.message(
'Ignoring scenario `$name` as tag expression `${configuration.tagExpression}` not satisfied',
MessageLevel.info,
);
}
}