Skip to content

Commit

Permalink
* Fixes #93 & #92 - Error waiting for no transient callbacks from Flu…
Browse files Browse the repository at this point in the history
…tter driver

* Added option to leave Flutter app under test running when the tests finish see `keepAppRunningAfterTests` configuration property
* Added the ability to have multiple example blocks with tags per scenario outline
  • Loading branch information
jonsamwell committed Nov 24, 2020
1 parent 956b2c2 commit 4b0ef61
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 63 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.1.9] - 24/11/2020
* Fixes #93 & #92 - Error waiting for no transient callbacks from Flutter driver
* Added option to leave Flutter app under test running when the tests finish see `keepAppRunningAfterTests` configuration property
* Added the ability to have multiple example blocks with tags per scenario outline

## [1.1.8+9] - 20/09/2020

* Fixes #84 - pre-defined `present within N seconds` is limited by system timeout (thanks @doubleo2)
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Available as a Dart package https://pub.dartlang.org/packages/flutter_gherkin
+ [Steps Definitions](#steps-definitions)
- [Given](#given)
- [Then](#then)
- [Expects Assertions](#expects-assertions)
- [Step Timeout](#step-timeout)
- [Multiline Strings](#multiline-strings)
- [Data tables](#data-tables)
Expand Down Expand Up @@ -484,6 +485,11 @@ This should point to the *testable* application that enables the Flutter driver
Defaults to `true`
This optional argument lets you specify if the target application should be built prior to running the first test. This defaults to `true`

#### keepAppRunningAfterTests

Defaults to `false`
This optional argument will keep the Flutter application running when done testing. This defaults to `false`

#### buildFlavor

Defaults to empty string
Expand Down Expand Up @@ -580,7 +586,9 @@ StepDefinitionGeneric ThenExpectAppleCount() {
}
```

**Caveat**: The `expect` library currently only works within the library's own `test` function blocks; so using it with a `Then` step will cause an error. Therefore, the `expectMatch` or `expectA` or `this.expect` methods have been added which mimic the underlying functionality of `except` in that they assert that the give is true. The `Matcher` within Dart's test library still work and can be used as expected.
#### Expects Assertions

**Caveat**: The `expect` library currently only works within the library's own `test` function blocks; so using it with a `Then` step will cause an error. Therefore, the `expectMatch` or `expectA` or `this.expect` or `context.expect` methods have been added which mimic the underlying functionality of `except` in that they assert that the give is true. The `Matcher` within Dart's test library still work and can be used as expected.

#### Step Timeout

Expand Down
2 changes: 1 addition & 1 deletion example/test_driver/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Future<void> main() {
..targetAppPath = 'test_driver/app.dart'
// ..buildFlavor = "staging" // uncomment when using build flavor and check android/ios flavor setup see android file android\app\build.gradle
// ..targetDeviceId = "all" // uncomment to run tests on all connected devices or set specific device target id
// ..tagExpression = '@smoke' // uncomment to see an example of running scenarios based on tag expressions
// ..tagExpression = '@smoke and not @ignore' // uncomment to see an example of running scenarios based on tag expressions
// ..logFlutterProcessOutput = true // uncomment to see command invoked to start the flutter test app
// ..verboseFlutterProcessLogs = true // uncomment to see the verbose output from the Flutter process
// ..flutterBuildTimeout = Duration(minutes: 3) // uncomment to change the default period that flutter is expected to build and start the app within
Expand Down
2 changes: 1 addition & 1 deletion example/test_driver/report.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions lib/src/flutter/flutter_run_process_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class FlutterRunProcessHandler extends ProcessHandler {
bool _buildApp = true;
bool _logFlutterProcessOutput = false;
bool _verboseFlutterLogs = false;
bool _keepAppRunning = false;
BuildMode _buildMode = BuildMode.Debug;
String _workingDirectory;
String _appTarget;
Expand Down Expand Up @@ -91,6 +92,10 @@ class FlutterRunProcessHandler extends ProcessHandler {
_verboseFlutterLogs = verbose;
}

void setKeepAppRunning(bool keepRunning) {
_keepAppRunning = keepRunning;
}

@override
Future<void> run() async {
final arguments = ['run', '--target=$_appTarget'];
Expand All @@ -117,6 +122,10 @@ class FlutterRunProcessHandler extends ProcessHandler {
arguments.add('--verbose');
}

if (_keepAppRunning) {
arguments.add('--keep-app-running');
}

if (_logFlutterProcessOutput) {
stdout.writeln(
'Invoking from working directory `${_workingDirectory ?? './'}` command: `flutter ${arguments.join(' ')}`',
Expand Down
4 changes: 4 additions & 0 deletions lib/src/flutter/flutter_test_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class FlutterTestConfiguration extends TestConfiguration {
/// Defaults to empty
String targetDeviceId = '';

/// Will keep the Flutter application running when done testing
/// Defaults to false
bool keepAppRunningAfterTests = false;

/// Logs Flutter process output to stdout
/// The Flutter process is use to start and driver the app under test.
/// The output may contain build and run information
Expand Down
1 change: 1 addition & 0 deletions lib/src/flutter/hooks/app_runner_hook.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class FlutterAppRunnerHook extends Hook {
..setDriverConnectionDelay(config.flutterDriverReconnectionDelay)
..setWorkingDirectory(config.targetAppWorkingDirectory)
..setBuildRequired(haveRunFirstScenario ? false : config.build)
..setKeepAppRunning(config.keepAppRunningAfterTests)
..setBuildFlavor(config.buildFlavor)
..setBuildMode(config.buildMode)
..setDeviceTargetId(config.targetDeviceId);
Expand Down
Loading

0 comments on commit 4b0ef61

Please sign in to comment.