diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 767068c..04aaefa 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-09-16 11:36:24.117283","version":"2.5.0"} \ 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-10-27 20:12:58.071212","version":"2.5.3"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 20a92dd..c807601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.0.0-rc.6] - 27/10/2021 + +- BREAKING CHANGE: Made `appMainFunction` return a `Future` so it can be async +- Fix: #159: Swipe step not working +- Ensure Hook.onBeforeRun is called before the run starts +- Set Frame policy- defaults to `LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive` to slightly improve performance + ## [3.0.0-rc.5] - 22/06/2021 - Ensure scenario support files (world etc) as always disposed ensure when test throws error diff --git a/example_with_integration_test/README.md b/example_with_integration_test/README.md index 2b61f0c..596f079 100644 --- a/example_with_integration_test/README.md +++ b/example_with_integration_test/README.md @@ -1,16 +1,7 @@ -# example_with_integration_test +``` +# generate the test suite +flutter pub run build_runner build -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +# run the tests +flutter drive --driver=test_driver/integration_test_driver.dart --target=integration_test/gherkin_suite_test.dart +``` diff --git a/example_with_integration_test/integration_test/gherkin/configuration.dart b/example_with_integration_test/integration_test/gherkin/configuration.dart index b8e618a..1449667 100644 --- a/example_with_integration_test/integration_test/gherkin/configuration.dart +++ b/example_with_integration_test/integration_test/gherkin/configuration.dart @@ -41,7 +41,7 @@ FlutterTestConfiguration gherkinTestConfiguration = ] ..createWorld = (config) => Future.value(CustomWorld()); -void Function(World) appInitializationFn = (World world) { +Future Function(World) appInitializationFn = (World world) async { // ensure a new injector instance is created each time final injector = Injector(DateTime.now().microsecondsSinceEpoch.toString()); final externalApplicationManager = ExternalApplicationManager(injector); diff --git a/example_with_integration_test/integration_test/gherkin/reports/integration_response_data.json b/example_with_integration_test/integration_test/gherkin/reports/integration_response_data.json index 5a65bfd..f353a26 100644 --- a/example_with_integration_test/integration_test/gherkin/reports/integration_response_data.json +++ b/example_with_integration_test/integration_test/gherkin/reports/integration_response_data.json @@ -1,3 +1,3 @@ { - "gherkin_reports": "[[{\"description\":\"\",\"id\":\"user can create a new todo item\",\"keyword\":\"Feature\",\"line\":1,\"name\":\"User can create a new todo item\",\"uri\":\"\",\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"},{\"line\":1,\"name\":\"@tag_two\"}],\"elements\":[{\"keyword\":\"Scenario\",\"type\":\"scenario\",\"id\":\"user can create a new todo item;user can create a new todo item\",\"name\":\"User can create a new todo item\",\"description\":\"\",\"line\":1,\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"},{\"line\":1,\"name\":\"@tag_two\"}],\"steps\":[{\"keyword\":\"Given \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy carrots\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":637000000}},{\"keyword\":\"When \",\"name\":\"I tap the 'add' button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":803000000}},{\"keyword\":\"Then \",\"name\":\"I expect the todo list\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":127000000},\"rows\":[{\"cells\":[\"Todo\"]},{\"cells\":[\"Buy carrots\"]}]}]},{\"keyword\":\"Scenario\",\"type\":\"scenario\",\"id\":\"user can create a new todo item;user can create multiple new todo items\",\"name\":\"User can create multiple new todo items\",\"description\":\"\",\"line\":1,\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@debug\"}],\"steps\":[{\"keyword\":\"Given \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy carrots\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":501000000}},{\"keyword\":\"When \",\"name\":\"I tap the \\\"add\\\" button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":719000000}},{\"keyword\":\"And \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy apples\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":379000000}},{\"keyword\":\"When \",\"name\":\"I tap the \\\"add\\\" button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":722000000}},{\"keyword\":\"And \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy blueberries\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":374000000}},{\"keyword\":\"When \",\"name\":\"I tap the \\\"add\\\" button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":720000000}},{\"keyword\":\"Then \",\"name\":\"I expect the todo list\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":367000000},\"rows\":[{\"cells\":[\"Todo\"]},{\"cells\":[\"Buy blueberries\"]},{\"cells\":[\"Buy apples\"]},{\"cells\":[\"Buy carrots\"]}]},{\"keyword\":\"Given \",\"name\":\"I wait 5 seconds for the animation to complete\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":113000000}}]}]},{\"description\":\"\",\"id\":\"user can have data\",\"keyword\":\"Feature\",\"line\":1,\"name\":\"User can have data\",\"uri\":\"\",\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"}],\"elements\":[{\"keyword\":\"Scenario\",\"type\":\"scenario\",\"id\":\"user can have data;user can have data\",\"name\":\"User can have data\",\"description\":\"\",\"line\":1,\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"}],\"steps\":[{\"keyword\":\"Given \",\"name\":\"I have item with data\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":0},\"docString\":{\"content_type\":\"\",\"value\":\"{\\n \\\"glossary\\\": {\\n \\\"title\\\": \\\"example glossary\\\",\\n \\\"GlossDiv\\\": {\\n \\\"title\\\": \\\"S\\\",\\n \\\"GlossList\\\": {\\n \\\"GlossEntry\\\": {\\n \\\"ID\\\": \\\"SGML\\\",\\n \\\"SortAs\\\": \\\"SGML\\\",\\n \\\"GlossTerm\\\": \\\"Standard Generalized Markup Language\\\",\\n \\\"Acronym\\\": \\\"SGML\\\",\\n \\\"Abbrev\\\": \\\"ISO 8879:1986\\\",\\n \\\"GlossDef\\\": {\\n \\\"para\\\": \\\"A meta-markup language, used to create markup languages such as DocBook.\\\",\\n \\\"GlossSeeAlso\\\": [\\n \\\"GML\\\",\\n \\\"XML\\\"\\n ]\\n },\\n \\\"GlossSee\\\": \\\"markup\\\"\\n }\\n }\\n }\\n }\\n}\",\"line\":2}}]}]}]]" + "gherkin_reports": "[[{\"description\":\"\",\"id\":\"user can create a new todo item\",\"keyword\":\"Feature\",\"line\":1,\"name\":\"User can create a new todo item\",\"uri\":\"\",\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"},{\"line\":1,\"name\":\"@tag_two\"}],\"elements\":[{\"keyword\":\"Scenario\",\"type\":\"scenario\",\"id\":\"user can create a new todo item;user can create a new todo item\",\"name\":\"User can create a new todo item\",\"description\":\"\",\"line\":1,\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"},{\"line\":1,\"name\":\"@tag_two\"}],\"steps\":[{\"keyword\":\"Given \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy carrots\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":541000000}},{\"keyword\":\"When \",\"name\":\"I tap the 'add' button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":714000000}},{\"keyword\":\"Then \",\"name\":\"I expect the todo list\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":124000000},\"rows\":[{\"cells\":[\"Todo\"]},{\"cells\":[\"Buy carrots\"]}]}]},{\"keyword\":\"Scenario\",\"type\":\"scenario\",\"id\":\"user can create a new todo item;user can create multiple new todo items\",\"name\":\"User can create multiple new todo items\",\"description\":\"\",\"line\":1,\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@debug\"}],\"steps\":[{\"keyword\":\"Given \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy carrots\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":469000000}},{\"keyword\":\"When \",\"name\":\"I tap the \\\"add\\\" button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":625000000}},{\"keyword\":\"And \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy apples\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":315000000}},{\"keyword\":\"When \",\"name\":\"I tap the \\\"add\\\" button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":825000000}},{\"keyword\":\"And \",\"name\":\"I fill the \\\"todo\\\" field with \\\"Buy blueberries\\\"\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":317000000}},{\"keyword\":\"When \",\"name\":\"I tap the \\\"add\\\" button\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":727000000}},{\"keyword\":\"Then \",\"name\":\"I expect the todo list\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":328000000},\"rows\":[{\"cells\":[\"Todo\"]},{\"cells\":[\"Buy blueberries\"]},{\"cells\":[\"Buy apples\"]},{\"cells\":[\"Buy carrots\"]}]},{\"keyword\":\"Given \",\"name\":\"I wait 5 seconds for the animation to complete\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":104000000}}]}]},{\"description\":\"\",\"id\":\"user can have data\",\"keyword\":\"Feature\",\"line\":1,\"name\":\"User can have data\",\"uri\":\"\",\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"}],\"elements\":[{\"keyword\":\"Scenario\",\"type\":\"scenario\",\"id\":\"user can have data;user can have data\",\"name\":\"User can have data\",\"description\":\"\",\"line\":1,\"tags\":[{\"line\":1,\"name\":\"@tag\"},{\"line\":1,\"name\":\"@tag1\"}],\"steps\":[{\"keyword\":\"Given \",\"name\":\"I have item with data\",\"line\":1,\"match\":{\"location\":\":1\"},\"result\":{\"status\":\"passed\",\"duration\":0},\"docString\":{\"content_type\":\"\",\"value\":\"{\\n \\\"glossary\\\": {\\n \\\"title\\\": \\\"example glossary\\\",\\n \\\"GlossDiv\\\": {\\n \\\"title\\\": \\\"S\\\",\\n \\\"GlossList\\\": {\\n \\\"GlossEntry\\\": {\\n \\\"ID\\\": \\\"SGML\\\",\\n \\\"SortAs\\\": \\\"SGML\\\",\\n \\\"GlossTerm\\\": \\\"Standard Generalized Markup Language\\\",\\n \\\"Acronym\\\": \\\"SGML\\\",\\n \\\"Abbrev\\\": \\\"ISO 8879:1986\\\",\\n \\\"GlossDef\\\": {\\n \\\"para\\\": \\\"A meta-markup language, used to create markup languages such as DocBook.\\\",\\n \\\"GlossSeeAlso\\\": [\\n \\\"GML\\\",\\n \\\"XML\\\"\\n ]\\n },\\n \\\"GlossSee\\\": \\\"markup\\\"\\n }\\n }\\n }\\n }\\n}\",\"line\":2}}]}]}]]" } \ No newline at end of file diff --git a/example_with_integration_test/integration_test/gherkin_suite_test.g.dart b/example_with_integration_test/integration_test/gherkin_suite_test.g.dart index d69d29b..d63af46 100644 --- a/example_with_integration_test/integration_test/gherkin_suite_test.g.dart +++ b/example_with_integration_test/integration_test/gherkin_suite_test.g.dart @@ -9,7 +9,7 @@ part of 'gherkin_suite_test.dart'; class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { _CustomGherkinIntegrationTestRunner( TestConfiguration configuration, - void Function(World) appMainFunction, + Future Function(World) appMainFunction, ) : super(configuration, appMainFunction); @override @@ -182,7 +182,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { void executeTestSuite( TestConfiguration configuration, - void Function(World) appMainFunction, + Future Function(World) appMainFunction, ) { _CustomGherkinIntegrationTestRunner(configuration, appMainFunction).run(); } diff --git a/example_with_integration_test/lib/models/todo_model.g.dart b/example_with_integration_test/lib/models/todo_model.g.dart index 6d366b1..177ddf3 100644 --- a/example_with_integration_test/lib/models/todo_model.g.dart +++ b/example_with_integration_test/lib/models/todo_model.g.dart @@ -10,7 +10,7 @@ Todo _$TodoFromJson(Map json) => Todo( id: json['id'] as String, created: DateTime.parse(json['created'] as String), updated: DateTime.parse(json['updated'] as String), - status: _$enumDecode(_$TodoStatusEnumMap, json['status']), + status: $enumDecode(_$TodoStatusEnumMap, json['status']), action: json['action'] as String?, ); @@ -22,32 +22,6 @@ Map _$TodoToJson(Todo instance) => { 'status': _$TodoStatusEnumMap[instance.status], }; -K _$enumDecode( - Map enumValues, - Object? source, { - K? unknownValue, -}) { - if (source == null) { - throw ArgumentError( - 'A value must be provided. Supported values: ' - '${enumValues.values.join(', ')}', - ); - } - - return enumValues.entries.singleWhere( - (e) => e.value == source, - orElse: () { - if (unknownValue == null) { - throw ArgumentError( - '`$source` is not one of the supported values: ' - '${enumValues.values.join(', ')}', - ); - } - return MapEntry(unknownValue, enumValues.values.first); - }, - ).key; -} - const _$TodoStatusEnumMap = { TodoStatus.pending: 'pending', TodoStatus.complete: 'complete', diff --git a/example_with_integration_test/pubspec.lock b/example_with_integration_test/pubspec.lock index 4ee2964..47db601 100644 --- a/example_with_integration_test/pubspec.lock +++ b/example_with_integration_test/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "25.0.0" + version: "30.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.7.0" archive: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" build_config: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" build_resolvers: dependency: transitive description: @@ -77,14 +77,14 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.4" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "7.1.0" + version: "7.2.2" built_collection: dependency: transitive description: @@ -126,7 +126,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.3" + version: "0.3.5" clock: dependency: transitive description: @@ -168,7 +168,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" fake_async: dependency: transitive description: @@ -213,7 +213,7 @@ packages: path: ".." relative: true source: path - version: "3.0.0-rc.3" + version: "3.0.0-rc.6" flutter_simple_dependency_injection: dependency: "direct main" description: @@ -256,7 +256,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" graphs: dependency: transitive description: @@ -303,14 +303,14 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.3.0" json_serializable: dependency: "direct main" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "6.0.1" logging: dependency: transitive description: @@ -338,7 +338,7 @@ packages: name: mime url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" package_config: dependency: transitive description: @@ -374,13 +374,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.3" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" platform: dependency: transitive description: @@ -394,7 +387,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" pool: dependency: transitive description: @@ -422,7 +415,7 @@ packages: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" rxdart: dependency: "direct main" description: @@ -436,7 +429,7 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.7" + version: "2.0.8" shared_preferences_linux: dependency: transitive description: @@ -497,14 +490,14 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" source_helper: dependency: transitive description: name: source_helper url: "https://pub.dartlang.org" source: hosted - version: "1.2.1" + version: "1.3.0" source_span: dependency: transitive description: @@ -581,7 +574,7 @@ packages: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.4" + version: "3.0.5" vector_math: dependency: transitive description: @@ -602,7 +595,7 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" web_socket_channel: dependency: transitive description: @@ -623,7 +616,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.2.9" + version: "2.2.10" xdg_directories: dependency: transitive description: diff --git a/example_with_integration_test/pubspec.yaml b/example_with_integration_test/pubspec.yaml index 2e4a462..9ab64ac 100644 --- a/example_with_integration_test/pubspec.yaml +++ b/example_with_integration_test/pubspec.yaml @@ -12,11 +12,11 @@ environment: dependencies: flutter: sdk: flutter - json_serializable: ^5.0.0 - json_annotation: ^4.1.0 + json_serializable: ^6.0.1 + json_annotation: ^4.3.0 rxdart: ^0.27.2 - shared_preferences: ^2.0.7 - uuid: ^3.0.4 + shared_preferences: ^2.0.8 + uuid: ^3.0.5 flutter_simple_dependency_injection: ^2.0.0 dev_dependencies: diff --git a/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart b/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart index 01a360f..7c7057a 100644 --- a/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart +++ b/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart @@ -18,9 +18,13 @@ class WidgetTesterAppDriverAdapter Duration? timeout = const Duration(seconds: 30), }) async { try { - return await nativeDriver.pumpAndSettle( - duration!, + final pumps = await nativeDriver.pumpAndSettle( + duration ?? const Duration(milliseconds: 100), + EnginePhase.sendSemanticsUpdate, + timeout ?? const Duration(seconds: 30), ); + + return pumps; } catch (_) { return 1; } 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 5f3f094..d53e645 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 @@ -16,7 +16,7 @@ class GherkinSuiteTestGenerator class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { _CustomGherkinIntegrationTestRunner( TestConfiguration configuration, - void Function(World) appMainFunction, + Future Function(World) appMainFunction, ) : super(configuration, appMainFunction); @override @@ -29,7 +29,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner { void executeTestSuite( TestConfiguration configuration, - void Function(World) appMainFunction, + Future Function(World) appMainFunction, ) { _CustomGherkinIntegrationTestRunner(configuration, appMainFunction).run(); } diff --git a/lib/src/flutter/runners/gherkin_integration_test_runner.dart b/lib/src/flutter/runners/gherkin_integration_test_runner.dart index ce41204..a4e84db 100644 --- a/lib/src/flutter/runners/gherkin_integration_test_runner.dart +++ b/lib/src/flutter/runners/gherkin_integration_test_runner.dart @@ -21,7 +21,7 @@ abstract class GherkinIntegrationTestRunner { final TagExpressionEvaluator _tagExpressionEvaluator = TagExpressionEvaluator(); final TestConfiguration configuration; - final void Function(World world) appMainFunction; + final Future Function(World world) appMainFunction; Reporter? _reporter; Hook? _hook; Iterable? _executableSteps; @@ -31,6 +31,7 @@ abstract class GherkinIntegrationTestRunner { Reporter get reporter => _reporter!; Hook get hook => _hook!; + LiveTestWidgetsFlutterBindingFramePolicy? get framePolicy => null; Timeout scenarioExecutionTimeout = const Timeout(Duration(minutes: 10)); @@ -53,7 +54,8 @@ abstract class GherkinIntegrationTestRunner { _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding; - _safeInvokeFuture(() async => await reporter.onTestRunStarted()); + _binding!.framePolicy = + framePolicy ?? LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive; tearDownAll( () { @@ -61,6 +63,9 @@ abstract class GherkinIntegrationTestRunner { }, ); + _safeInvokeFuture(() async => await hook.onBeforeRun(configuration)); + _safeInvokeFuture(() async => await reporter.onTestRunStarted()); + onRun(); } @@ -217,7 +222,7 @@ abstract class GherkinIntegrationTestRunner { WidgetTester tester, World world, ) async { - appMainFunction(world); + await appMainFunction(world); await tester.pumpAndSettle(); } diff --git a/lib/src/flutter/steps/swipe_step.dart b/lib/src/flutter/steps/swipe_step.dart index dc49510..36f0b89 100644 --- a/lib/src/flutter/steps/swipe_step.dart +++ b/lib/src/flutter/steps/swipe_step.dart @@ -1,4 +1,4 @@ -import 'package:flutter_driver/flutter_driver.dart'; +import 'package:flutter_gherkin/flutter_gherkin.dart'; import 'package:flutter_gherkin/src/flutter/world/flutter_world.dart'; import 'package:gherkin/gherkin.dart'; @@ -7,7 +7,7 @@ import '../parameters/swipe_direction_parameter.dart'; mixin _SwipeHelper on When3WithWorld { Future swipeOnFinder( - SerializableFinder finder, + dynamic finder, SwipeDirection direction, int swipeAmount, ) async { @@ -52,7 +52,7 @@ class SwipeOnKeyStep int swipeAmount, String key, ) async { - final finder = find.byValueKey(key); + final finder = this.world.appDriver.findBy(key, FindType.key); await swipeOnFinder(finder, direction, swipeAmount); } @@ -75,7 +75,7 @@ class SwipeOnTextStep int swipeAmount, String text, ) async { - final finder = find.text(text); + final finder = this.world.appDriver.findBy(text, FindType.text); await swipeOnFinder(finder, direction, swipeAmount); } diff --git a/pubspec.lock b/pubspec.lock index 6bcee36..6fb59a7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "26.0.0" + version: "30.0.0" analyzer: dependency: "direct main" description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "2.3.0" + version: "2.7.0" archive: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" build_config: dependency: "direct dev" description: @@ -84,7 +84,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.3.3" + version: "0.3.5" clock: dependency: transitive description: @@ -119,7 +119,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" fake_async: dependency: transitive description: @@ -167,7 +167,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" integration_test: dependency: "direct main" description: flutter @@ -179,7 +179,7 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.3.0" logging: dependency: transitive description: @@ -261,7 +261,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.1" source_span: dependency: transitive description: @@ -338,7 +338,7 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" webdriver: dependency: transitive description: @@ -354,5 +354,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.3 <3.0.0" + dart: ">=2.14.0 <3.0.0" flutter: ">=2.2.0" diff --git a/pubspec.yaml b/pubspec.yaml index 702801c..de8ba8e 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: 3.0.0-rc.5 +version: 3.0.0-rc.6 homepage: https://github.com/jonsamwell/flutter_gherkin environment: @@ -19,9 +19,9 @@ dependencies: analyzer: ">=1.7.1 <3.0.0" collection: ^1.15.0 gherkin: ^2.0.5+1 - source_gen: ^1.1.0 - build: ^2.1.0 - glob: ^2.0.1 + source_gen: ^1.1.1 + build: ^2.1.1 + glob: ^2.0.2 # gherkin: # path: ../dart_gherkin