diff --git a/CHANGELOG.md b/CHANGELOG.md index 78c4a11..6800ae5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.1.7+1] - 07/01/2019 +* Ensured when the Flutter driver is closed it cannot throw an unhandled exception causing the test run the stop +* Updated Gherkin library version + ## [1.1.7] - 06/01/2019 * `WhenFillFieldStep` Ensure widget is scrolled into view before setting it's value * Fixed lint warnings diff --git a/lib/src/flutter/flutter_world.dart b/lib/src/flutter/flutter_world.dart index 4375053..e6f25a2 100644 --- a/lib/src/flutter/flutter_world.dart +++ b/lib/src/flutter/flutter_world.dart @@ -18,10 +18,10 @@ class FlutterWorld extends World { _flutterRunProcessHandler = flutterRunProcessHandler; } - Future restartApp( - {Duration timeout = const Duration(seconds: 60)}) async { - await _driver.waitUntilNoTransientCallbacks(); - await _driver.close(); + Future restartApp({ + Duration timeout = const Duration(seconds: 60), + }) async { + await _closeDriver(timeout: timeout); final result = await _flutterRunProcessHandler?.restart( timeout: timeout, ); @@ -37,6 +37,21 @@ class FlutterWorld extends World { void dispose() async { super.dispose(); _flutterRunProcessHandler = null; - await _driver?.close(); + await _closeDriver(timeout: const Duration(seconds: 5)); + } + + Future _closeDriver({ + Duration timeout = const Duration(seconds: 60), + }) async { + try { + if (_driver != null) { + await _driver.waitUntilNoTransientCallbacks(timeout: timeout); + await _driver.close(); + } + } catch (e, st) { + print('Error closing Flutter driver:\n\n`${e}`\n\n${st}'); + } finally { + _driver = null; + } } } diff --git a/pubspec.lock b/pubspec.lock index 1d9a886..ce2f537 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -118,7 +118,7 @@ packages: name: gherkin url: "https://pub.dartlang.org" source: hosted - version: "1.1.5+1" + version: "1.1.5+2" glob: dependency: "direct main" description: @@ -139,7 +139,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.0+3" + version: "0.12.0+4" http_multi_server: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 091c807..7712c39 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: sdk: flutter glob: ^1.1.7 meta: ">=1.1.6 <2.0.0" - gherkin: ^1.1.5+1 + gherkin: ^1.1.5+2 dev_dependencies: test: