-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
package:patrol
for Android e2e tests. (#1137)
Use [`package:patrol`](https://pub.dev/packages/patrol) for integration/e2e tests for Android. The biggest benefit is that each test can run from a completely clean state, which is not possible with the `integration_test` package. Because of this we shouldn't have the issues with e.g. the auth state being kept for each test (or logging out and back in which breaks stuff). For other platforms I kept our old tests (renamed to `integration_test/integration_test_old.dart`): * Web should theoretically work as long as no native interaction is used, but I couldn't set it up practically. There is an [open issue for web ](leancodepl/patrol#733) in their repo. * iOS should work, but I couldn't get it running. * macOS is never mentioned, so I don't know if it's possible to run tests for mac. From https://patrol.leancode.co/: > Patrol lets you [access native features of the platform](https://patrol.leancode.co/native/overview) that the Flutter app is running on. Finally, you can interact with permission dialogs, notifications, WebViews, change device settings, toggle Wi-Fi, and much more – and you can code this very easily in plain Dart. > > Patrol also provides a [new custom finder system](https://patrol.leancode.co/finders/overview) that extends Flutter's default finders, making them shorter and easier to understand. Patrol's custom finders, coupled with [Hot Restart](https://patrol.leancode.co/cli-commands/develop), make writing integration tests dramatically faster, easier and more fun! Command to running the tests: ``` patrol build android \ --flavor prod \ --dart-define [email protected] \ --dart-define USER_1_PASSWORD=foobar \ -t integration_test/app_test.dart ```
- Loading branch information
1 parent
b441d82
commit 210a8b6
Showing
18 changed files
with
409 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ jobs: | |
# (~5% of the time) build takes longer and then is a long timeout needed. | ||
defaults: | ||
run: | ||
working-directory: app/android | ||
working-directory: app | ||
timeout-minutes: 90 | ||
steps: | ||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 | ||
|
@@ -99,18 +99,10 @@ jobs: | |
flutter-version: ${{ env.FLUTTER_VERSION }} | ||
channel: ${{ env.FLUTTER_CHANNEL }} | ||
|
||
- name: Build Instrumentation Test | ||
env: | ||
# In gradlew, we can't just pass --dart-define as we do with "flutter | ||
# test". We need to convert the key and the value into base64, like | ||
# "[email protected]" becomes to | ||
# "VVNFUl8xX0VNQUlMPXVzZXJAZXhhbXBsZS5jb20=". | ||
# | ||
# The secrets already contain the base64 encoded values. We don't | ||
# encode them in the workflow file, because we could easily leak the | ||
# base64 encoded version in logs. | ||
USER_1_EMAIL_BASE64: ${{ secrets.INTEGRATION_TEST_USER_1_EMAIL_DART_DEFINE_BASE64 }} | ||
USER_1_PASSWORD_BASE64: ${{ secrets.INTEGRATION_TEST_USER_1_PASSWORD_DART_DEFINE_BASE64 }} | ||
- name: Install patrol cli | ||
run: flutter pub global activate patrol_cli ^2.2.1 | ||
|
||
- name: Run Flutter build | ||
run: | | ||
# Flutter build is required to generate files in android/ to build the | ||
# gradle project. | ||
|
@@ -119,14 +111,17 @@ jobs: | |
# Firebase Test Lab with the dev flavor. We always got "No tests | ||
# found.". | ||
flutter build apk \ | ||
--target=lib/main_prod.dart \ | ||
--flavor prod \ | ||
--config-only | ||
--target=lib/main_prod.dart \ | ||
--flavor prod \ | ||
--config-only | ||
./gradlew app:assembleProdDebugAndroidTest | ||
./gradlew app:assembleProdDebug \ | ||
-Ptarget=integration_test/app_test.dart \ | ||
-Pdart-defines="$USER_1_EMAIL_BASE64,$USER_1_PASSWORD_BASE64" | ||
- name: Build Instrumentation Test | ||
run: | | ||
patrol build android \ | ||
--flavor prod \ | ||
--dart-define USER_1_EMAIL=${{ secrets.INTEGRATION_TEST_USER_1_EMAIL }} \ | ||
--dart-define USER_1_PASSWORD=${{ secrets.INTEGRATION_TEST_USER_1_PASSWORD }} \ | ||
-t integration_test/app_test.dart | ||
- name: Setup credentials | ||
env: | ||
|
@@ -153,10 +148,12 @@ jobs: | |
run: | | ||
gcloud firebase test android run \ | ||
--type instrumentation \ | ||
--app ../build/app/outputs/apk/prod/debug/app-prod-debug.apk \ | ||
--test ../build/app/outputs/apk/androidTest/prod/debug/app-prod-debug-androidTest.apk \ | ||
--app build/app/outputs/apk/prod/debug/app-prod-debug.apk \ | ||
--test build/app/outputs/apk/androidTest/prod/debug/app-prod-debug-androidTest.apk \ | ||
--device model=Pixel2,version=30,locale=en,orientation=portrait \ | ||
--timeout 3m | ||
--timeout 10m \ | ||
--use-orchestrator \ | ||
--environment-variables clearPackageData=true | ||
# It can easily happen that a dependency changed but the .lock file is not | ||
# updated. Or other cases where files are changed during a build. | ||
|
@@ -229,7 +226,7 @@ jobs: | |
# https://github.com/flutter/flutter/issues/88690 | ||
fvm flutter drive \ | ||
--driver=test_driver/integration_test.dart \ | ||
--target=integration_test/app_test.dart \ | ||
--target=integration_test/integration_test_old.dart \ | ||
--flavor prod \ | ||
--dart-define=USER_1_EMAIL=$USER_1_EMAIL \ | ||
--dart-define=USER_1_PASSWORD=$USER_1_PASSWORD \ | ||
|
@@ -274,7 +271,7 @@ jobs: | |
chromedriver --port=4444 & | ||
fvm flutter drive \ | ||
--driver=test_driver/integration_test.dart \ | ||
--target=integration_test/app_test.dart \ | ||
--target=integration_test/integration_test_old.dart \ | ||
--flavor dev \ | ||
--dart-define=USER_1_EMAIL=$USER_1_EMAIL \ | ||
--dart-define=USER_1_PASSWORD=$USER_1_PASSWORD \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_bundle.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.