execute method
Implementation
Future<void> execute(TestConfiguration testConfiguration) async {
final config = testConfiguration.prepare();
_registerReporters(config.reporters);
_registerHooks(config.hooks);
_registerCustomParameters(config.customStepParameterDefinitions);
_registerStepDefinitions(config.stepDefinitions);
_languageService.initialise(config.featureDefaultLanguage);
var featureFiles = await _getFeatureFiles(config);
var allFeaturesPassed = true;
if (config.order == ExecutionOrder.random) {
await _reporter.message(
'Executing features in random order',
MessageLevel.info,
);
featureFiles = featureFiles.toList()..shuffle();
} else if (config.order == ExecutionOrder.alphabetical) {
await _reporter.message(
'Executing features in sorted order',
MessageLevel.info,
);
featureFiles.sort(
(FeatureFile a, FeatureFile b) => a.name.compareTo(b.name),
);
}
await _hook.onBeforeRun(config);
try {
await _reporter.test.onStarted.invoke();
for (final featureFile in featureFiles) {
final runner = FeatureFileRunner(
config: config,
tagExpressionEvaluator: _tagExpressionEvaluator,
steps: _executableSteps,
reporter: _reporter,
hook: _hook,
);
allFeaturesPassed &= await runner.run(featureFile);
if (config.stopAfterTestFailed && !allFeaturesPassed) {
break;
}
}
} finally {
await _reporter.test.onFinished.invoke();
await _hook.onAfterRun(config);
await _reporter.dispose();
}
if (!allFeaturesPassed) {
throw GherkinTestRunFailedException();
}
}