fix(driver): increased the Flutter driver reconnection delay to try and overcome some driver to app connection issues on slower machines

This commit is contained in:
Jon Samwell 2020-01-07 17:02:13 +11:00
parent 3fab3ca2e9
commit 6fd30a6492
6 changed files with 18 additions and 4 deletions

View File

@ -1,3 +1,6 @@
## [1.1.7+2] - 07/01/2019
* Increased the Flutter driver reconnection delay to try and overcome some driver to app connection issues on slower machines
## [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

View File

@ -41,6 +41,7 @@ class FlutterRunProcessHandler extends ProcessHandler {
String _appTarget;
String _buildFlavor;
String _deviceTargetId;
Duration _driverConnectionDelay = const Duration(seconds: 2);
String currentObservatoryUri;
void setLogFlutterProcessOutput(bool logFlutterProcessOutput) {
@ -51,6 +52,10 @@ class FlutterRunProcessHandler extends ProcessHandler {
_appTarget = targetPath;
}
void setDriverConnectionDelay(Duration duration) {
_driverConnectionDelay = duration ?? _driverConnectionDelay;
}
void setWorkingDirectory(String workingDirectory) {
_workingDirectory = workingDirectory;
}
@ -146,7 +151,7 @@ class FlutterRunProcessHandler extends ProcessHandler {
// it seems we need a small delay here otherwise the flutter driver fails to
// consistently connect
await Future.delayed(Duration(seconds: 1));
await Future.delayed(_driverConnectionDelay);
return Future.value(true);
}

View File

@ -52,7 +52,12 @@ class FlutterTestConfiguration extends TestConfiguration {
/// Duration to wait for Flutter to build and start the app on the target device
/// Slower machine may take longer to build and run a large app
/// Defaults to 90 seconds
Duration flutterBuildTimeout = Duration(seconds: 90);
Duration flutterBuildTimeout = const Duration(seconds: 90);
/// Duration to wait before reconnecting the Flutter driver to the app.
/// On slower machines the app might not be in a state where the driver can successfully connect immediately
/// Defaults to 2 seconds
Duration flutterDriverReconnectionDelay = const Duration(seconds: 2);
void setObservatoryDebuggerUri(String uri) => _observatoryDebuggerUri = uri;

View File

@ -49,7 +49,7 @@ class FlutterWorld extends World {
await _driver.close();
}
} catch (e, st) {
print('Error closing Flutter driver:\n\n`${e}`\n\n${st}');
print('Error closing Flutter driver:\n\n`$e`\n\n$st');
} finally {
_driver = null;
}

View File

@ -62,6 +62,7 @@ class FlutterAppRunnerHook extends Hook {
..setLogFlutterProcessOutput(config.logFlutterProcessOutput)
..setVerboseFluterlogs(config.verboseFlutterProcessLogs)
..setApplicationTargetFile(config.targetAppPath)
..setDriverConnectionDelay(config.flutterDriverReconnectionDelay)
..setWorkingDirectory(config.targetAppWorkingDirecotry)
..setBuildRequired(haveRunFirstScenario ? false : config.build)
..setBuildFlavor(config.buildFlavor)

View File

@ -1,6 +1,6 @@
name: flutter_gherkin
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
version: 1.1.7+1
version: 1.1.7+2
author: Jon Samwell <jonsamwell@gmail.com>
homepage: https://github.com/jonsamwell/flutter_gherkin