diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index dfb7b26..8a490eb 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-05-01 13:05:07.936285","version":"2.0.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-05-01 15:02:07.460210","version":"2.0.5"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b10e0cf..10b0df9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,9 @@ In order to progress this library and add support for the new integration_test package various things have had to be changed to enable this will still supporting Flutter Driver. The big of which is removing Flutter Driver instance from the `FlutterWorld` instance in favour of an adapter approach whereby driving of the app (whether that is via `flutter_driver` or `WidgetTester`) becomes agnostic see `https://github.com/jonsamwell/flutter_gherkin/blob/f1fb2d4a632362629f5d1a196a0c055f858ad1d7/lib/src/flutter/adapters/app_driver_adapter.dart`. - `FlutterDriverUtils` has been removed, use `world.appDriver` instead. You can still access the raw driver if needed via `world.appDriver.rawDriver` -- If you are using a custom world object and still want to use Flutter Driver it will need to extend `FlutterDriverWorld` instead of `FlutterWorld` +- If you are using a custom world object and still want to use Flutter Driver it will need to extend `FlutterDriverWorld` instead of `FlutterWorld` this will give you type safety on the `world.appDriver.rawDriver` property -The change to use the `integration_test` package is a fundamentally different approach. Where using the `flutter_driver` implementation your app is launch in a different process and then controlled by remote RPC calls from the flutter driver again in a different process. Using the new `integration_test` package your tests surround your app and become the app themselves. This removes the need for RPC communication from an external process into the app as well as giving you access to the internal state of your app. This is an altogether better approach, one that is quicker, more maintainable scalable to device testing labs. However, it brings with it, its own set of challenges when trying to make this library work with it. Traditionally this library has evaluated the Gherkin feature files at run time, then used that evaluation to invoke actions against the app under test. However, as the tests need to surround the app in the `integration_test` view of the world the Gherkin tests need to be generated at development time so they can be complied in to a test app. Much like `json_serializable` creates classes that are able to work with json data. +The change to use the `integration_test` package is a fundamentally different approach. Where using the `flutter_driver` implementation your app is launch in a different process and then controlled by remote RPC calls from flutter driver in a different process. Using the new `integration_test` package your tests surround your app and become the app themselves. This removes the need for RPC communication from an external process into the app as well as giving you access to the internal state of your app. This is an altogether better approach, one that is quicker, more maintainable, scalable to device testing labs. However, it brings with it, its own set of challenges when trying to make this library work with it. Traditionally this library has evaluated the Gherkin feature files at run time, then used that evaluation to invoke actions against the app under test. However, as the tests need to surround the app in the `integration_test` view of the world the Gherkin tests need to be generated at development time so they can be complied in to a test app. Much like `json_serializable` creates classes that are able to work with json data. ### Steps to get going diff --git a/example_with_integration_test/integration_test/gherkin_suite_test.dart b/example_with_integration_test/integration_test/gherkin_suite_test.dart index 87ffec7..802a40c 100644 --- a/example_with_integration_test/integration_test/gherkin_suite_test.dart +++ b/example_with_integration_test/integration_test/gherkin_suite_test.dart @@ -1,12 +1,14 @@ import 'package:flutter_gherkin/flutter_gherkin.dart'; import 'package:gherkin/gherkin.dart'; +import 'gherkin/configuration.dart'; + part 'gherkin_suite_test.g.dart'; @GherkinTestSuite() void main() { - // executeTestSuite( - // gherkinTestConfiguration, - // appInitializationFn, - // ); + executeTestSuite( + gherkinTestConfiguration, + appInitializationFn, + ); } diff --git a/example_with_integration_test/lib/widgets/components/add_todo_component.dart b/example_with_integration_test/lib/widgets/components/add_todo_component.dart index c3e4605..637cbd6 100644 --- a/example_with_integration_test/lib/widgets/components/add_todo_component.dart +++ b/example_with_integration_test/lib/widgets/components/add_todo_component.dart @@ -28,7 +28,7 @@ class _AddTodoComponentState extends State widget.todo.takeUntil(disposed$).listen( (model) { setState(() { - _textEditingController.text = model.action ?? ''; + _textEditingController.text = model.action; }); }, ); diff --git a/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart b/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart index 6e03d40..9c1f640 100644 --- a/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart +++ b/lib/src/flutter/code_generation/generators/gherkin_suite_test_generator.dart @@ -57,7 +57,8 @@ void executeTestSuite( .listValue .map((path) => Glob(path.toStringValue()!)) .map( - (glob) => glob.listSync() + (glob) => glob + .listSync() .map((entity) => File(entity.path).readAsStringSync()) .toList(), ) diff --git a/pre-publish-checks.cmd b/pre-publish-checks.cmd index edc9bcc..901a269 100644 --- a/pre-publish-checks.cmd +++ b/pre-publish-checks.cmd @@ -1,4 +1,4 @@ CALL flutter analyze CALL "C:\Google\flutter\bin\cache\dart-sdk\bin\dartfmt" . -w CALL flutter packages upgrade -CALL flutter test \ No newline at end of file +CALL flutter test --no-sound-null-safety \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index ac31c84..68ff173 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -23,12 +23,12 @@ packages: source: hosted version: "2.0.13" args: - dependency: transitive + dependency: "direct overridden" description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "2.1.0" async: dependency: transitive description: @@ -112,7 +112,7 @@ packages: name: coverage url: "https://pub.dartlang.org" source: hosted - version: "0.15.2" + version: "1.0.2" crypto: dependency: "direct overridden" description: @@ -152,10 +152,17 @@ packages: source: sdk version: "0.0.0" flutter_test: - dependency: "direct main" + dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" fuchsia_remote_debug_protocol: dependency: transitive description: flutter @@ -169,7 +176,7 @@ packages: source: hosted version: "2.0.0" glob: - dependency: "direct dev" + dependency: transitive description: name: glob url: "https://pub.dartlang.org" @@ -190,7 +197,7 @@ packages: source: hosted version: "4.0.0" integration_test: - dependency: "direct dev" + dependency: "direct main" description: flutter source: sdk version: "0.9.2+2" @@ -249,7 +256,7 @@ packages: name: node_preamble url: "https://pub.dartlang.org" source: hosted - version: "1.4.13" + version: "2.0.0" package_config: dependency: transitive description: @@ -403,12 +410,12 @@ packages: source: hosted version: "1.2.0" test: - dependency: "direct dev" + dependency: "direct overridden" description: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.5" + version: "1.17.3" test_api: dependency: "direct overridden" description: @@ -422,7 +429,7 @@ packages: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.15" + version: "0.3.23" typed_data: dependency: transitive description: @@ -438,12 +445,12 @@ packages: source: hosted version: "2.1.0" vm_service: - dependency: transitive + dependency: "direct overridden" description: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "5.5.0" + version: "6.2.0" watcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index dde28cc..9ba1d41 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.2.0 +version: 2.0.0 homepage: https://github.com/jonsamwell/flutter_gherkin environment: @@ -10,7 +10,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_test: + integration_test: sdk: flutter flutter_driver: sdk: flutter @@ -23,18 +23,18 @@ dependencies: # ref: f0b3f955191b53a78075ed2c9387ea8bee12f111 dependency_overrides: - crypto: ^3.0.0 # flutter_driver still depends on 2.1.5 :-( - convert: ^3.0.0 # flutter_driver still depends on >=2.0.0 :-( - test: ^1.16.5 # gherkin still depends on 1.16.8 :-( - test_api: ^0.3.0 # flutter_test still depends on 0.2.19 :-( + crypto: ^3.0.0 # flutter_driver still depends on 2.1.5 see https://github.com/flutter/flutter/issues/80293 + convert: ^3.0.0 # flutter_driver still depends on >=2.0.0 see https://github.com/flutter/flutter/issues/80293 + test_api: ^0.3.0 # flutter_test still depends on 0.2.19 see https://github.com/flutter/flutter/issues/80293 + vm_service: ^6.0.0 # flutter_test still depends on 5.5.0 see https://github.com/flutter/flutter/issues/80293 + test: ^1.17.3 # integration_test still depends on 1.16.6 see https://github.com/flutter/flutter/issues/71379 + args: ^2.0.0 # flutter_driver still depends on 1.6.0 see https://github.com/flutter/flutter/issues/80293 dev_dependencies: - integration_test: + flutter_test: sdk: flutter - test: ^1.16.5 meta: ^1.3.0 pedantic: ^1.11.0 - glob: ^2.0.1 source_gen: ^1.0.0 build: ^2.0.1 build_config: ^1.0.0 diff --git a/test/flutter_configuration_test.dart b/test/flutter_configuration_test.dart index 2b20a51..c7e349e 100644 --- a/test/flutter_configuration_test.dart +++ b/test/flutter_configuration_test.dart @@ -1,6 +1,7 @@ import 'package:flutter_gherkin/flutter_gherkin_with_driver.dart'; import 'package:flutter_gherkin/src/flutter/hooks/app_runner_hook.dart'; -import 'package:test/test.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:test/test.dart' as test; import 'mocks/parameter_mock.dart'; import 'mocks/step_definition_mock.dart'; @@ -8,7 +9,7 @@ import 'mocks/step_definition_mock.dart'; void main() { group('config', () { group('prepare', () { - test('flutter app runner hook added', () { + test.test('flutter app runner hook added', () { final config = FlutterDriverTestConfiguration(); expect(config.hooks, isNull); config.prepare(); @@ -17,7 +18,7 @@ void main() { expect(config.hooks!.elementAt(0), (x) => x is FlutterAppRunnerHook); }); - test('common steps definition added', () { + test.test('common steps definition added', () { final config = FlutterDriverTestConfiguration(); expect(config.stepDefinitions, isNull); @@ -28,7 +29,7 @@ void main() { expect(config.customStepParameterDefinitions!.length, 2); }); - test('common step definition added to existing steps', () { + test.test('common step definition added to existing steps', () { final config = FlutterTestConfiguration() ..stepDefinitions = [MockStepDefinition()] ..customStepParameterDefinitions = [MockParameter()];