- BREAKING CHANGE: Made `appMainFunction` return a `Future<void>` 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
This commit is contained in:
Jon Samwell 2021-10-27 20:13:49 +11:00
parent 3c0e1c6270
commit 2db755d23b
15 changed files with 78 additions and 104 deletions

View File

@ -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"}
{"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"}

View File

@ -1,3 +1,10 @@
## [3.0.0-rc.6] - 27/10/2021
- BREAKING CHANGE: Made `appMainFunction` return a `Future<void>` 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

View File

@ -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
```

View File

@ -41,7 +41,7 @@ FlutterTestConfiguration gherkinTestConfiguration =
]
..createWorld = (config) => Future.value(CustomWorld());
void Function(World) appInitializationFn = (World world) {
Future<void> 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);

View File

@ -9,7 +9,7 @@ part of 'gherkin_suite_test.dart';
class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
_CustomGherkinIntegrationTestRunner(
TestConfiguration configuration,
void Function(World) appMainFunction,
Future<void> Function(World) appMainFunction,
) : super(configuration, appMainFunction);
@override
@ -182,7 +182,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
void executeTestSuite(
TestConfiguration configuration,
void Function(World) appMainFunction,
Future<void> Function(World) appMainFunction,
) {
_CustomGherkinIntegrationTestRunner(configuration, appMainFunction).run();
}

View File

@ -10,7 +10,7 @@ Todo _$TodoFromJson(Map<String, dynamic> 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<String, dynamic> _$TodoToJson(Todo instance) => <String, dynamic>{
'status': _$TodoStatusEnumMap[instance.status],
};
K _$enumDecode<K, V>(
Map<K, V> 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',

View File

@ -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:

View File

@ -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:

View File

@ -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;
}

View File

@ -16,7 +16,7 @@ class GherkinSuiteTestGenerator
class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
_CustomGherkinIntegrationTestRunner(
TestConfiguration configuration,
void Function(World) appMainFunction,
Future<void> Function(World) appMainFunction,
) : super(configuration, appMainFunction);
@override
@ -29,7 +29,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
void executeTestSuite(
TestConfiguration configuration,
void Function(World) appMainFunction,
Future<void> Function(World) appMainFunction,
) {
_CustomGherkinIntegrationTestRunner(configuration, appMainFunction).run();
}

View File

@ -21,7 +21,7 @@ abstract class GherkinIntegrationTestRunner {
final TagExpressionEvaluator _tagExpressionEvaluator =
TagExpressionEvaluator();
final TestConfiguration configuration;
final void Function(World world) appMainFunction;
final Future<void> Function(World world) appMainFunction;
Reporter? _reporter;
Hook? _hook;
Iterable<ExecutableStep>? _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();
}

View File

@ -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<SwipeDirection, int, String, FlutterWorld> {
Future<void> 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);
}

View File

@ -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"

View File

@ -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