From 76e6a841e0c140fae8c437d4492f38e23ca06eea Mon Sep 17 00:00:00 2001 From: Jon Samwell Date: Thu, 26 Sep 2019 08:00:06 +1000 Subject: [PATCH] feat(flutter): added ability to change flutter build timeout and now logging flutter command run --- CHANGELOG.md | 4 ++++ README.md | 14 +++++++++++ example/report.json | 2 +- example/test_driver/app_test.dart | 1 + .../flutter/flutter_run_process_handler.dart | 23 +++++++++++++++---- .../flutter/flutter_test_configuration.dart | 5 ++++ lib/src/flutter/hooks/app_runner_hook.dart | 17 ++++++++++---- pubspec.yaml | 2 +- 8 files changed, 56 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a529bbd..0d4209f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.1.4] - 26/09/2019 +* Added configuration parameter `flutterBuildTimeout` to allow setting the app build wait timeout. Slower machine may need longer to build and start a Flutter app under test. +* Now logging the flutter driver command used when the configuration setting `logFlutterProcessOutput` is true + ## [1.1.3] - 25/09/2019 * Added Flutter driver reporter - the Flutter Driver logs all messages (even non-error ones) to stderr and will cause the process to be marked as failed by a CI server becuase of this. So this reporter redirects the messages to the appropiate output stream (stdout / stderr). * FlutterWorld - added missing `super.dispose()` call diff --git a/README.md b/README.md index d74f4eb..63ed7dd 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ Available as a Dart package https://pub.dartlang.org/packages/flutter_gherkin - [hooks](#hooks) - [reporters](#reporters) - [createWorld](#createworld) + - [logFlutterProcessOutput](#logFlutterProcessOutput) + - [flutterBuildTimeout](#flutterBuildTimeout) - [exitAfterTestRun](#exitaftertestrun) - [Flutter specific configuration options](#flutter-specific-configuration-options) - [restartAppBetweenScenarios](#restartappbetweenscenarios) @@ -432,6 +434,18 @@ Future main() { } ``` +#### logFlutterProcessOutput + +Defaults to `false` + +If `true` the output from the flutter process is logged to the stdout / stderr streams. Useful when debugging app build or start failures + +#### flutterBuildTimeout + +Defaults to `90 seconds` + +Specifies the period of time to wait for the Flutter build to complete and the app to be installed and in a state to be tested. Slower machines may need longer than the default 90 seconds to complete this process. + #### exitAfterTestRun Defaults to `true` diff --git a/example/report.json b/example/report.json index 9b1444f..db2c9e8 100644 --- a/example/report.json +++ b/example/report.json @@ -1 +1 @@ -[{"description":"","id":"custom parameter example","keyword":"Feature","line":1,"name":"Custom Parameter Example","uri":".\\test_driver\\features\\custom_parameter_example.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"custom parameter example;custom colour parameter","name":"Custom colour parameter","description":"","line":4,"steps":[{"keyword":"Given ","name":"I pick the colour red","line":5,"match":{"location":".\\test_driver\\features\\custom_parameter_example.feature:5"},"result":{"status":"passed","duration":1000000}},{"keyword":"Given ","name":"I pick the colour green","line":6,"match":{"location":".\\test_driver\\features\\custom_parameter_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I pick the colour blue","line":7,"match":{"location":".\\test_driver\\features\\custom_parameter_example.feature:7"},"result":{"status":"passed","duration":0}}]}]},{"description":"","id":"counter","keyword":"Feature","line":1,"name":"Counter","uri":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature","elements":[{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 1)","name":"Counter increases when the button is pressed (Example 1)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":33000000}},{"keyword":"When ","name":"I tap the \"increment\" button 1 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":292000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"1\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":20000000}}]},{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 2)","name":"Counter increases when the button is pressed (Example 2)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":33000000}},{"keyword":"When ","name":"I tap the \"increment\" button 2 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":532000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"2\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":26000000}}]},{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 3)","name":"Counter increases when the button is pressed (Example 3)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button 5 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":1269000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"5\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":24000000}}]},{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 4)","name":"Counter increases when the button is pressed (Example 4)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":33000000}},{"keyword":"When ","name":"I tap the \"increment\" button 10 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":2495000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"10\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":24000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":2,"name":"Counter","uri":".\\test_driver\\features\\counter_increases_french.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter;counter increases when the button is pressed","name":"Counter increases when the button is pressed","description":"","line":6,"tags":[{"line":5,"name":"@smoke"}],"steps":[{"keyword":"Etant ","name":"donné que I pick the colour red","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:7"},"result":{"status":"passed","duration":0}},{"keyword":"Et ","name":"I expect the \"counter\" to be \"0\"","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:8"},"result":{"status":"passed","duration":29000000}},{"keyword":"Quand ","name":"I tap the \"increment\" button 10 times","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:9"},"result":{"status":"passed","duration":2497000000}},{"keyword":"Alors ","name":"I expect the \"counter\" to be \"10\"","line":10,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:10"},"result":{"status":"passed","duration":23000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":1,"name":"Counter","uri":".\\test_driver\\features\\counter_increases.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter;counter increases when the button is pressed","name":"Counter increases when the button is pressed","description":"","line":5,"tags":[{"line":4,"name":"@smoke"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases.feature:7"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button 10 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases.feature:8"},"result":{"status":"passed","duration":2500000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"10\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases.feature:9"},"result":{"status":"passed","duration":30000000}}]}]},{"description":"","id":"startup","keyword":"Feature","line":1,"name":"Startup","uri":".\\test_driver\\features\\counter.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"startup;should increment counter","name":"should increment counter","description":"","line":3,"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":4,"match":{"location":".\\test_driver\\features\\counter.feature:4"},"result":{"status":"passed","duration":30000000}},{"keyword":"When ","name":"I tap the \"increment\" button","line":5,"match":{"location":".\\test_driver\\features\\counter.feature:5"},"result":{"status":"passed","duration":291000000}},{"keyword":"And ","name":"I tap the \"increment\" button","line":6,"match":{"location":".\\test_driver\\features\\counter.feature:6"},"result":{"status":"passed","duration":245000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"2\"","line":7,"match":{"location":".\\test_driver\\features\\counter.feature:7"},"result":{"status":"passed","duration":23000000}}]},{"keyword":"Scenario","type":"scenario","id":"startup;counter should reset when app is restarted","name":"counter should reset when app is restarted","description":"","line":9,"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":10,"match":{"location":".\\test_driver\\features\\counter.feature:10"},"result":{"status":"passed","duration":30000000}},{"keyword":"When ","name":"I tap the \"increment\" button","line":11,"match":{"location":".\\test_driver\\features\\counter.feature:11"},"result":{"status":"passed","duration":303000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"1\"","line":12,"match":{"location":".\\test_driver\\features\\counter.feature:12"},"result":{"status":"passed","duration":26000000}},{"keyword":"When ","name":"I restart the app","line":13,"match":{"location":".\\test_driver\\features\\counter.feature:13"},"result":{"status":"passed","duration":2070000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"0\"","line":14,"match":{"location":".\\test_driver\\features\\counter.feature:14"},"result":{"status":"passed","duration":33000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":1,"name":"Counter","uri":".\\test_driver\\features\\sub-features\\counter_increases.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter;counter increases when the button is pressed","name":"Counter increases when the button is pressed","description":"","line":5,"tags":[{"line":4,"name":"@perf"}],"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":6,"match":{"location":".\\test_driver\\features\\sub-features\\counter_increases.feature:6"},"result":{"status":"passed","duration":30000000}},{"keyword":"When ","name":"I tap the \"increment\" button 20 times","line":7,"match":{"location":".\\test_driver\\features\\sub-features\\counter_increases.feature:7"},"result":{"status":"passed","duration":4893000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"20\"","line":8,"match":{"location":".\\test_driver\\features\\sub-features\\counter_increases.feature:8"},"result":{"status":"passed","duration":21000000}}]}]},{"description":"","id":"startup","keyword":"Feature","line":1,"name":"Startup","uri":".\\test_driver\\features\\app_restart.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"startup;counter should reset when app is restarted","name":"counter should reset when app is restarted","description":"","line":3,"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":4,"match":{"location":".\\test_driver\\features\\app_restart.feature:4"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button","line":5,"match":{"location":".\\test_driver\\features\\app_restart.feature:5"},"result":{"status":"passed","duration":287000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"1\"","line":6,"match":{"location":".\\test_driver\\features\\app_restart.feature:6"},"result":{"status":"passed","duration":22000000}},{"keyword":"When ","name":"I restart the app","line":7,"match":{"location":".\\test_driver\\features\\app_restart.feature:7"},"result":{"status":"passed","duration":2074000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"0\"","line":8,"match":{"location":".\\test_driver\\features\\app_restart.feature:8"},"result":{"status":"passed","duration":32000000}}]}]},{"description":"","id":"drawer","keyword":"Feature","line":1,"name":"Drawer","uri":".\\test_driver\\features\\drawer.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"drawer;should open the drawer","name":"should open the drawer","description":"","line":3,"steps":[{"keyword":"Given ","name":"I open the drawer","line":4,"match":{"location":".\\test_driver\\features\\drawer.feature:4"},"result":{"status":"passed","duration":1445000000}},{"keyword":"Given ","name":"I close the drawer","line":5,"match":{"location":".\\test_driver\\features\\drawer.feature:5"},"result":{"status":"passed","duration":388000000}}]}]}] \ No newline at end of file +[{"description":"","id":"startup","keyword":"Feature","line":1,"name":"Startup","uri":".\\test_driver\\features\\app_restart.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"startup;counter should reset when app is restarted","name":"counter should reset when app is restarted","description":"","line":3,"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":4,"match":{"location":".\\test_driver\\features\\app_restart.feature:4"},"result":{"status":"passed","duration":42000000}},{"keyword":"When ","name":"I tap the \"increment\" button","line":5,"match":{"location":".\\test_driver\\features\\app_restart.feature:5"},"result":{"status":"passed","duration":293000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"1\"","line":6,"match":{"location":".\\test_driver\\features\\app_restart.feature:6"},"result":{"status":"passed","duration":25000000}},{"keyword":"When ","name":"I restart the app","line":7,"match":{"location":".\\test_driver\\features\\app_restart.feature:7"},"result":{"status":"passed","duration":2171000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"0\"","line":8,"match":{"location":".\\test_driver\\features\\app_restart.feature:8"},"result":{"status":"passed","duration":31000000}}]}]},{"description":"","id":"drawer","keyword":"Feature","line":1,"name":"Drawer","uri":".\\test_driver\\features\\drawer.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"drawer;should open the drawer","name":"should open the drawer","description":"","line":3,"steps":[{"keyword":"Given ","name":"I open the drawer","line":4,"match":{"location":".\\test_driver\\features\\drawer.feature:4"},"result":{"status":"passed","duration":1462000000}},{"keyword":"Given ","name":"I close the drawer","line":5,"match":{"location":".\\test_driver\\features\\drawer.feature:5"},"result":{"status":"passed","duration":388000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":1,"name":"Counter","uri":".\\test_driver\\features\\counter_increases.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter;counter increases when the button is pressed","name":"Counter increases when the button is pressed","description":"","line":5,"tags":[{"line":4,"name":"@smoke"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases.feature:7"},"result":{"status":"passed","duration":32000000}},{"keyword":"When ","name":"I tap the \"increment\" button 10 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases.feature:8"},"result":{"status":"passed","duration":2508000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"10\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases.feature:9"},"result":{"status":"passed","duration":25000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":1,"name":"Counter","uri":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature","elements":[{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 1)","name":"Counter increases when the button is pressed (Example 1)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button 1 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":295000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"1\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":24000000}}]},{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 2)","name":"Counter increases when the button is pressed (Example 2)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button 2 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":546000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"2\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":26000000}}]},{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 3)","name":"Counter increases when the button is pressed (Example 3)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":36000000}},{"keyword":"When ","name":"I tap the \"increment\" button 5 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":1279000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"5\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":25000000}}]},{"keyword":"Scenario Outline","type":"scenario","id":"counter;counter increases when the button is pressed (example 4)","name":"Counter increases when the button is pressed (Example 4)","description":"","line":5,"tags":[{"line":4,"name":"@scenario_outline"}],"steps":[{"keyword":"Given ","name":"I pick the colour red","line":6,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:7"},"result":{"status":"passed","duration":33000000}},{"keyword":"When ","name":"I tap the \"increment\" button 10 times","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:8"},"result":{"status":"passed","duration":2472000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"10\"","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_scenerio_outline_example.feature:9"},"result":{"status":"passed","duration":26000000}}]}]},{"description":"","id":"startup","keyword":"Feature","line":1,"name":"Startup","uri":".\\test_driver\\features\\counter.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"startup;should increment counter","name":"should increment counter","description":"","line":3,"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":4,"match":{"location":".\\test_driver\\features\\counter.feature:4"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button","line":5,"match":{"location":".\\test_driver\\features\\counter.feature:5"},"result":{"status":"passed","duration":307000000}},{"keyword":"And ","name":"I tap the \"increment\" button","line":6,"match":{"location":".\\test_driver\\features\\counter.feature:6"},"result":{"status":"passed","duration":239000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"2\"","line":7,"match":{"location":".\\test_driver\\features\\counter.feature:7"},"result":{"status":"passed","duration":23000000}}]},{"keyword":"Scenario","type":"scenario","id":"startup;counter should reset when app is restarted","name":"counter should reset when app is restarted","description":"","line":9,"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":10,"match":{"location":".\\test_driver\\features\\counter.feature:10"},"result":{"status":"passed","duration":34000000}},{"keyword":"When ","name":"I tap the \"increment\" button","line":11,"match":{"location":".\\test_driver\\features\\counter.feature:11"},"result":{"status":"passed","duration":301000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"1\"","line":12,"match":{"location":".\\test_driver\\features\\counter.feature:12"},"result":{"status":"passed","duration":23000000}},{"keyword":"When ","name":"I restart the app","line":13,"match":{"location":".\\test_driver\\features\\counter.feature:13"},"result":{"status":"passed","duration":2076000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"0\"","line":14,"match":{"location":".\\test_driver\\features\\counter.feature:14"},"result":{"status":"passed","duration":37000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":1,"name":"Counter","uri":".\\test_driver\\features\\sub-features\\counter_increases.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter;counter increases when the button is pressed","name":"Counter increases when the button is pressed","description":"","line":5,"tags":[{"line":4,"name":"@perf"}],"steps":[{"keyword":"Given ","name":"I expect the \"counter\" to be \"0\"","line":6,"match":{"location":".\\test_driver\\features\\sub-features\\counter_increases.feature:6"},"result":{"status":"passed","duration":31000000}},{"keyword":"When ","name":"I tap the \"increment\" button 20 times","line":7,"match":{"location":".\\test_driver\\features\\sub-features\\counter_increases.feature:7"},"result":{"status":"passed","duration":4927000000}},{"keyword":"Then ","name":"I expect the \"counter\" to be \"20\"","line":8,"match":{"location":".\\test_driver\\features\\sub-features\\counter_increases.feature:8"},"result":{"status":"passed","duration":24000000}}]}]},{"description":"","id":"counter","keyword":"Feature","line":2,"name":"Counter","uri":".\\test_driver\\features\\counter_increases_french.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"counter;counter increases when the button is pressed","name":"Counter increases when the button is pressed","description":"","line":6,"tags":[{"line":5,"name":"@smoke"}],"steps":[{"keyword":"Etant ","name":"donné que I pick the colour red","line":7,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:7"},"result":{"status":"passed","duration":0}},{"keyword":"Et ","name":"I expect the \"counter\" to be \"0\"","line":8,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:8"},"result":{"status":"passed","duration":32000000}},{"keyword":"Quand ","name":"I tap the \"increment\" button 10 times","line":9,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:9"},"result":{"status":"passed","duration":2504000000}},{"keyword":"Alors ","name":"I expect the \"counter\" to be \"10\"","line":10,"match":{"location":".\\test_driver\\features\\counter_increases_french.feature:10"},"result":{"status":"passed","duration":27000000}}]}]},{"description":"","id":"custom parameter example","keyword":"Feature","line":1,"name":"Custom Parameter Example","uri":".\\test_driver\\features\\custom_parameter_example.feature","elements":[{"keyword":"Scenario","type":"scenario","id":"custom parameter example;custom colour parameter","name":"Custom colour parameter","description":"","line":4,"steps":[{"keyword":"Given ","name":"I pick the colour red","line":5,"match":{"location":".\\test_driver\\features\\custom_parameter_example.feature:5"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I pick the colour green","line":6,"match":{"location":".\\test_driver\\features\\custom_parameter_example.feature:6"},"result":{"status":"passed","duration":0}},{"keyword":"Given ","name":"I pick the colour blue","line":7,"match":{"location":".\\test_driver\\features\\custom_parameter_example.feature:7"},"result":{"status":"passed","duration":0}}]}]}] \ No newline at end of file diff --git a/example/test_driver/app_test.dart b/example/test_driver/app_test.dart index 8fda7c0..11b4fa2 100644 --- a/example/test_driver/app_test.dart +++ b/example/test_driver/app_test.dart @@ -32,6 +32,7 @@ Future main() { // ..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 // ..logFlutterProcessOutput = true // uncomment to see the 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 ..exitAfterTestRun = true; // set to false if debugging to exit cleanly return GherkinRunner().execute(config); } diff --git a/lib/src/flutter/flutter_run_process_handler.dart b/lib/src/flutter/flutter_run_process_handler.dart index 29c3140..120af06 100644 --- a/lib/src/flutter/flutter_run_process_handler.dart +++ b/lib/src/flutter/flutter_run_process_handler.dart @@ -72,8 +72,18 @@ class FlutterRunProcessHandler extends ProcessHandler { arguments.add("--device-id=$_deviceTargetId"); } - _runningProcess = await Process.start("flutter", arguments, - workingDirectory: _workingDirectory, runInShell: true); + if (_logFlutterProcessOutput) { + stdout.writeln( + 'Invoking from working directory `${_workingDirectory ?? './'}` command: `flutter ${arguments.join(' ')}`'); + } + + _runningProcess = await Process.start( + "flutter", + arguments, + workingDirectory: _workingDirectory, + runInShell: true, + ); + _processStdoutStream = _runningProcess.stdout.transform(utf8.decoder).asBroadcastStream(); @@ -123,10 +133,13 @@ class FlutterRunProcessHandler extends ProcessHandler { return Future.value(true); } - Future waitForObservatoryDebuggerUri() async { + Future waitForObservatoryDebuggerUri( + [Duration timeout = const Duration(seconds: 90)]) async { currentObservatoryUri = await _waitForStdOutMessage( - _observatoryDebuggerUriRegex, - "Timeout while waiting for observatory debugger uri"); + _observatoryDebuggerUriRegex, + "Timeout while waiting for observatory debugger uri", + timeout, + ); return currentObservatoryUri; } diff --git a/lib/src/flutter/flutter_test_configuration.dart b/lib/src/flutter/flutter_test_configuration.dart index 7e5fa85..b2766b7 100644 --- a/lib/src/flutter/flutter_test_configuration.dart +++ b/lib/src/flutter/flutter_test_configuration.dart @@ -44,6 +44,11 @@ class FlutterTestConfiguration extends TestConfiguration { /// The output may contain build and run information bool logFlutterProcessOutput = false; + /// 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); + void setObservatoryDebuggerUri(String uri) => _observatoryDebuggerUri = uri; Future createFlutterDriver([String dartVmServiceUrl]) async { diff --git a/lib/src/flutter/hooks/app_runner_hook.dart b/lib/src/flutter/hooks/app_runner_hook.dart index 08a6249..a15320d 100644 --- a/lib/src/flutter/hooks/app_runner_hook.dart +++ b/lib/src/flutter/hooks/app_runner_hook.dart @@ -25,7 +25,9 @@ class FlutterAppRunnerHook extends Hook { @override Future onBeforeScenario( - TestConfiguration config, String scenario) async { + TestConfiguration config, + String scenario, + ) async { final flutterConfig = _castConfig(config); if (_flutterRunProcessHandler == null) { await _runApp(flutterConfig); @@ -34,7 +36,9 @@ class FlutterAppRunnerHook extends Hook { @override Future onAfterScenario( - TestConfiguration config, String scenario) async { + TestConfiguration config, + String scenario, + ) async { final flutterConfig = _castConfig(config); haveRunFirstScenario = true; if (_flutterRunProcessHandler != null && @@ -44,7 +48,10 @@ class FlutterAppRunnerHook extends Hook { } @override - Future onAfterScenarioWorldCreated(World world, String scenario) async { + Future onAfterScenarioWorldCreated( + World world, + String scenario, + ) async { if (world is FlutterWorld) { world.setFlutterProccessHandler(_flutterRunProcessHandler); } @@ -64,8 +71,8 @@ class FlutterAppRunnerHook extends Hook { stdout.writeln( "Starting Flutter app under test '${config.targetAppPath}', this might take a few moments"); await _flutterRunProcessHandler.run(); - final observatoryUri = - await _flutterRunProcessHandler.waitForObservatoryDebuggerUri(); + final observatoryUri = await _flutterRunProcessHandler + .waitForObservatoryDebuggerUri(config.flutterBuildTimeout); config.setObservatoryDebuggerUri(observatoryUri); } diff --git a/pubspec.yaml b/pubspec.yaml index 9db4c05..d16e16e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_gherkin description: A Gherkin / Cucumber parser and test runner for Dart and Flutter -version: 1.1.3 +version: 1.1.4 author: Jon Samwell homepage: https://github.com/jonsamwell/flutter_gherkin