diff --git a/lib/src/scenario_generator.dart b/lib/src/scenario_generator.dart index e8ee957..c111b17 100644 --- a/lib/src/scenario_generator.dart +++ b/lib/src/scenario_generator.dart @@ -14,9 +14,7 @@ void parseScenario( List tags, String scenarioParams, ) { - sb.writeln( - " $testMethodName('''$scenarioTitle''', ($testerName) async {", - ); + sb.writeln(" $testMethodName('''$scenarioTitle''', ($testerName) async {"); if (hasHooks) { sb.writeln(' var $testSuccessVariableName = true;'); } @@ -38,7 +36,7 @@ void parseScenario( } if (hasHooks) { - sb.writeln(' } on TestFailure {'); + sb.writeln(' } catch (_) {'); sb.writeln(' $testSuccessVariableName = false;'); sb.writeln(' rethrow;'); } @@ -67,9 +65,7 @@ void parseScenario( for (final param in scenarioParams.split(', ')) { sb.writeln(' $param,'); } - sb.writeln( - ' );', - ); + sb.writeln(' );'); } } @@ -86,9 +82,7 @@ List> generateScenariosFromScenarioOutline( .toList(); } -List> _getExamples( - List scenario, -) { +List> _getExamples(List scenario) { final exampleLines = scenario .skipWhile((l) => l.type != LineType.exampleTitle) .where((l) => l.type == LineType.examples) diff --git a/test/feature_generator_test.dart b/test/feature_generator_test.dart index 6ea7c92..14b6d86 100644 --- a/test/feature_generator_test.dart +++ b/test/feature_generator_test.dart @@ -43,8 +43,10 @@ void main() { test('existing step should not regenerate', () async { const scenario = 'existing_step'; - final dummyStepPath = - p.join(getStepFolderName(scenario), 'the_app_is_running.dart'); + final dummyStepPath = p.join( + getStepFolderName(scenario), + 'the_app_is_running.dart', + ); const expectedFileContent = '// existing step'; fs.file(dummyStepPath) ..createSync(recursive: true) @@ -66,8 +68,11 @@ relativeToTestFolder: false ..writeAsStringSync(bddOptions); const scenario = 'existing_step_outside_test_folder'; - final dummyStepPath = - p.join(fs.currentDirectory.path, 'my_steps', 'the_app_is_running.dart'); + final dummyStepPath = p.join( + fs.currentDirectory.path, + 'my_steps', + 'the_app_is_running.dart', + ); fs.file(dummyStepPath) ..createSync(recursive: true) ..writeAsStringSync('dummy'); @@ -139,7 +144,7 @@ hookFolderName: hooksFolder ' try {\n' " await beforeEach('''Testing scenario''');\n" ' await theAppIsRunning(tester);\n' - ' } on TestFailure {\n' + ' } catch (_) {\n' ' success = false;\n' ' rethrow;\n' ' } finally {\n' @@ -164,10 +169,7 @@ hookFolderName: hooksFolder ..writeAsStringSync(bddOptions); const scenario = 'options'; - expect( - () => generate(scenario), - throwsException, - ); + expect(() => generate(scenario), throwsException); }); test('merge options', () async { @@ -260,9 +262,7 @@ stepFolderName: ./scenarios const scenario = 'options'; final content = await generate( scenario, - const BuilderOptions({ - 'include': externalYaml3, - }), + const BuilderOptions({'include': externalYaml3}), ); expect(content, expected); }); diff --git a/test/feature_with_hooks_test.dart b/test/feature_with_hooks_test.dart index bb8491e..2b76b5e 100644 --- a/test/feature_with_hooks_test.dart +++ b/test/feature_with_hooks_test.dart @@ -36,7 +36,7 @@ void main() { try { await beforeEach(\'\'\'Testing scenario\'\'\' ); await theAppIsRunning(tester); - } on TestFailure { + } catch (_) { success = false; rethrow; } finally { diff --git a/test/full_set_test.dart b/test/full_set_test.dart index a5d12ec..d052f5b 100644 --- a/test/full_set_test.dart +++ b/test/full_set_test.dart @@ -67,7 +67,7 @@ void main() { await theAppIsRunning(tester); await iRunCode(tester, 'func foo() {}; func bar() { print("hey!"); };'); await iSeeText(tester, '0'); - } on TestFailure { + } catch (_) { success = false; rethrow; } finally { @@ -96,7 +96,7 @@ void main() { await beforeEach(\'\'\'Initial counter value is 0\'\'\' ); await bddSetUp(tester); await theAppIsRunning(tester); - } on TestFailure { + } catch (_) { success = false; rethrow; } finally {