From 07472daaf117275bbc8b6f2a9ee717dc573a8f34 Mon Sep 17 00:00:00 2001 From: Jon Samwell Date: Wed, 31 Oct 2018 16:01:55 +1100 Subject: [PATCH] docs(example): added quick start steps in the example app readme --- CHANGELOG.md | 4 ++ README.md | 2 + example/README.md | 23 ++++++++--- example/test_driver/app_test.dart | 9 +++-- example/test_driver/app_test_old.dart | 40 ------------------- .../features/counter_increases.feature | 1 + example/test_driver/features/drawer.feature | 4 +- pubspec.yaml | 2 +- 8 files changed, 33 insertions(+), 52 deletions(-) delete mode 100644 example/test_driver/app_test_old.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index eb43497..1c0c388 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [0.0.6] - 31/10/2018 + +* Added quick start steps in the example app readme + ## [0.0.5] - 29/10/2018 * Sorted out formatting of pre-defined steps diff --git a/README.md b/README.md index b612343..c6fb55d 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ This implementation of the Gherkin tries to follow as closely as possible other See for information on the Gherkin syntax and Behaviour Driven Development (BDD). +See [example readme](example/README.md) for a quick start guide to running the example features and app. + The first step is to create a version of your app that has flutter driver enabled so that it can be automated. A good guide how to do this is show [here](https://flutter.io/cookbook/testing/integration-test-introduction/#4-instrument-the-app). However in short, create a folder called `test_driver` and within that create a file called `app.dart` and paste in the below code. ```dart diff --git a/example/README.md b/example/README.md index 64a12f6..9bf8343 100644 --- a/example/README.md +++ b/example/README.md @@ -1,8 +1,21 @@ -# example +# Running the example -A new Flutter project. +To run this example: -## Getting Started +1. Ensure dart is accessible in the command line (on your path variable) +2. Ensure an emulator or device is connected +3. In a command prompt (from the root of this library): + ```bash + cd example -For help getting started with Flutter, view our online -[documentation](https://flutter.io/). + dart test_driver/app_test.dart + ``` +This will run the features files found in the folder `test_driver/features` against this example app. + +## Debugging the example + +To debug this example and step through the library code. + +1. Set a break point in `test_driver/app_test.dart` +2. If you are in VsCode you will simply be able to select `Debug example` from the dropdown in the `debugging tab` as the `launch.json` has been configured. + - otherwise you will need to run a debugging session against `test_driver/app_test.dart`. diff --git a/example/test_driver/app_test.dart b/example/test_driver/app_test.dart index 4fbbfce..5b949e0 100644 --- a/example/test_driver/app_test.dart +++ b/example/test_driver/app_test.dart @@ -8,13 +8,16 @@ import 'steps/tap_button_n_times_step.dart'; Future main() { final config = FlutterTestConfiguration() - ..features = [Glob(r"test_driver/features/**/*.feature")] - ..reporters = [ProgressReporter()] + ..features = [Glob(r"test_driver/features/*.feature")] + ..reporters = [ + ProgressReporter() + ] // you can include the "StdoutReporter()" for more verbose information ..hooks = [HookExample()] ..stepDefinitions = [TapButtonNTimesStep(), GivenIPickAColour()] ..customStepParameterDefinitions = [ColourParameter()] ..restartAppBetweenScenarios = true ..targetAppPath = "test_driver/app.dart" - ..exitAfterTestRun = true; + // ..tagExpression = "@smoke" // uncomment to see an example of running scenarios based on tag expressions + ..exitAfterTestRun = true; // set to false if debugging to exit cleanly return GherkinRunner().execute(config); } diff --git a/example/test_driver/app_test_old.dart b/example/test_driver/app_test_old.dart deleted file mode 100644 index 76d55f2..0000000 --- a/example/test_driver/app_test_old.dart +++ /dev/null @@ -1,40 +0,0 @@ -// // Imports the Flutter Driver API -// import 'package:flutter_driver/flutter_driver.dart'; -// import 'package:test/test.dart'; - -// void main() { -// group('Counter App', () { -// // First, define the Finders. We can use these to locate Widgets from the -// // test suite. Note: the Strings provided to the `byValueKey` method must -// // be the same as the Strings we used for the Keys in step 1. -// final counterTextFinder = find.byValueKey('counter'); -// final buttonFinder = find.byValueKey('increment'); - -// FlutterDriver driver; - -// // Connect to the Flutter driver before running any tests -// setUpAll(() async { -// driver = await FlutterDriver.connect(); -// }); - -// // Close the connection to the driver after the tests have completed -// tearDownAll(() async { -// if (driver != null) { -// driver.close(); -// } -// }); - -// test('starts at 0', () async { -// // Use the `driver.getText` method to verify the counter starts at 0. -// expect(await driver.getText(counterTextFinder), "0"); -// }); - -// test('increments the counter', () async { -// // First, tap on the button -// await driver.tap(buttonFinder); - -// // Then, verify the counter text has been incremented by 1 -// expect(await driver.getText(counterTextFinder), "1"); -// }); -// }); -// } diff --git a/example/test_driver/features/counter_increases.feature b/example/test_driver/features/counter_increases.feature index bed39c8..1c27be1 100644 --- a/example/test_driver/features/counter_increases.feature +++ b/example/test_driver/features/counter_increases.feature @@ -1,6 +1,7 @@ Feature: Counter The counter should be incremented when the button is pressed. + @smoke Scenario: Counter increases when the button is pressed Given I expect the "counter" to be "0" When I tap the "increment" button 10 times diff --git a/example/test_driver/features/drawer.feature b/example/test_driver/features/drawer.feature index 4d89353..dff575f 100644 --- a/example/test_driver/features/drawer.feature +++ b/example/test_driver/features/drawer.feature @@ -2,6 +2,4 @@ Feature: Drawer Scenario: should open the drawer Given I open the drawer - # Given I close the drawer - # Then I see the menu item "Item 1" - # And I see the menu item "Item 2" + Given I close the drawer diff --git a/pubspec.yaml b/pubspec.yaml index f2878ed..b5126e8 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: 0.0.5 +version: 0.0.6 author: Jon Samwell homepage: https://github.com/jonsamwell/flutter_gherkin