Skip to content

Commit

Permalink
- BREAKING CHANGE: Made appMainFunction return a Future<void> so …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jonsamwell committed Oct 27, 2021
1 parent 3c0e1c6 commit 2db755d
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -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"}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 6 additions & 15 deletions example_with_integration_test/README.md
Original file line number Diff line number Diff line change
@@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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}}]}]}]]"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 1 addition & 27 deletions example_with_integration_test/lib/models/todo_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 21 additions & 28 deletions example_with_integration_test/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions example_with_integration_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
Expand Down
Loading

0 comments on commit 2db755d

Please sign in to comment.