diff --git a/lib/src/hooks/aggregated_hook.dart b/lib/src/hooks/aggregated_hook.dart index a845302..27a2d2b 100644 --- a/lib/src/hooks/aggregated_hook.dart +++ b/lib/src/hooks/aggregated_hook.dart @@ -4,34 +4,32 @@ import 'package:flutter_gherkin/src/hooks/hook.dart'; class AggregatedHook extends Hook { Iterable _orderedHooks; - + void addHooks(Iterable hooks) { - _orderedHooks = hooks.toList() - ..sort((a, b) => b.priority - a.priority); + _orderedHooks = hooks.toList()..sort((a, b) => b.priority - a.priority); } - + Future onBeforeRun(TestConfiguration config) async => - await _invokeHooks((h) => h.onBeforeRun(config)); - + await _invokeHooks((h) => h.onBeforeRun(config)); + /// Run after all scenerios in a test run have completed Future onAfterRun(TestConfiguration config) async => - await _invokeHooks((h) => h.onAfterRun(config)); - - Future onAfterScenarioWorldCreated(World world, - String scenario) async => - await _invokeHooks((h) => - h.onAfterScenarioWorldCreated(world, scenario)); - + await _invokeHooks((h) => h.onAfterRun(config)); + + Future onAfterScenarioWorldCreated( + World world, String scenario) async => + await _invokeHooks((h) => h.onAfterScenarioWorldCreated(world, scenario)); + /// Run before a scenario and it steps are executed - Future onBeforeScenario(TestConfiguration config, - String scenario) async => - await _invokeHooks((h) => h.onBeforeScenario(config, scenario)); - + Future onBeforeScenario( + TestConfiguration config, String scenario) async => + await _invokeHooks((h) => h.onBeforeScenario(config, scenario)); + /// Run after a scenario has executed - Future onAfterScenario(TestConfiguration config, - String scenario) async => - await _invokeHooks((h) => h.onAfterScenario(config, scenario)); - + Future onAfterScenario( + TestConfiguration config, String scenario) async => + await _invokeHooks((h) => h.onAfterScenario(config, scenario)); + Future _invokeHooks(Future invoke(Hook h)) async { if (_orderedHooks != null && _orderedHooks.length > 0) { for (var hook in _orderedHooks) { diff --git a/lib/src/hooks/hook.dart b/lib/src/hooks/hook.dart index 2d94d06..e93f011 100644 --- a/lib/src/hooks/hook.dart +++ b/lib/src/hooks/hook.dart @@ -16,7 +16,7 @@ abstract class Hook { /// Run after the scenario world is created but run before a scenario and its steps are executed /// Might not be invoked if there is not a world object Future onAfterScenarioWorldCreated(World world, String scenario) => - Future.value(null); + Future.value(null); /// Run before a scenario and it steps are executed Future onBeforeScenario(TestConfiguration config, String scenario) => diff --git a/test/mocks/step_definition_mock.dart b/test/mocks/step_definition_mock.dart index 58f2e36..defac0f 100644 --- a/test/mocks/step_definition_mock.dart +++ b/test/mocks/step_definition_mock.dart @@ -8,7 +8,8 @@ class MockStepDefinition extends StepDefinitionBase { int runCount = 0; final OnRunCode code; - MockStepDefinition([this.code, int expectedParameterCount = 0]) : super(null, expectedParameterCount); + MockStepDefinition([this.code, int expectedParameterCount = 0]) + : super(null, expectedParameterCount); @override Future onRun(Iterable parameters) async {