[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[e2e] update README #2233

Merged
merged 2 commits into from
Oct 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.1+1

* Updated README.

## 0.2.1

* Support the v2 Android embedder.
Expand Down
28 changes: 22 additions & 6 deletions packages/e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# e2e

This package enables self-driving testing of Flutter code on devices and emulators.
It can adapt the test results in a format that is compatible with `flutter drive`
It adapts flutter_test results into a format that is compatible with `flutter drive`
and native Android instrumentation testing.

iOS support is not available yet, but is planned in the future.
Expand All @@ -27,12 +27,19 @@ void main() {
}
```

## Test locations

It is recommended to put e2e tests in the `test/` folder of the app or package.
For example apps, if the e2e test references example app code, it should go in
`example/test/`. It is also acceptable to put e2e tests in `test_driver/` folder
so that they're alongside the runner app (see below).

## Using Flutter driver to run tests

`E2EWidgetsTestBinding` supports launching the on-device tests with `flutter drive`.
Note that the tests don't use the `FlutterDriver` API, they use `testWidgets` instead.

Put the a file named `<package_name>_test.dart` in the app' `test_driver` directory:
Put the a file named `<package_name>_e2e_test.dart` in the app' `test_driver` directory:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does flutter test scans _test.dart in a directory and execute them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It only looks in the test/ directory by default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then when executing flutter test without an attached device, the _e2e_test.dart will execute. Is it expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flutter test only looks for tests in the test/ folder. test_driver/ is ignored.


```
import 'package:flutter_driver/flutter_driver.dart';
Expand Down Expand Up @@ -106,22 +113,27 @@ dependencies {
To e2e test on a local Android device (emulated or physical):

```
./gradlew connectedAndroidTest -Ptarget=`pwd`/../test_driver/<package_name>_e2e.dart
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/<package_name>_e2e.dart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suffix should be _e2e.dart or _e2e_test.dart as above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suffix here should be _e2e.dart. The _e2e_test.dart suffix is reserved for the driver runner (which I hope will be unnecessary in the future).

```

## Firebase Test Lab

If this is you first time testing with Firebase Test Lab,
you'll need to follow the guides in the
[Firebase test lab documentation](https://firebase.google.com/docs/test-lab/?gclid=EAIaIQobChMIs5qVwqW25QIV8iCtBh3DrwyUEAAYASAAEgLFU_D_BwE)
to set up a project.

To run an e2e test on Android devices using Firebase Test Lab, use gradle commands to build an
instrumentation test for Android.

```
pushd android
./gradlew assembleAndroidTest
./gradlew assembleDebug -Ptarget=<path_to_test>.dart
./gradlew app:assembleAndroidTest
./gradlew app:assembleDebug -Ptarget=<path_to_test>.dart
popd
```

Upload to Firebase Test Lab, making sure to replace <PATH_TO_KEY_FILE>,
Upload the build apks Firebase Test Lab, making sure to replace <PATH_TO_KEY_FILE>,
<PROJECT_NAME>, <RESULTS_BUCKET>, and <RESULTS_DIRECTORY> with your values.

```
Expand All @@ -135,4 +147,8 @@ gcloud firebase test android run --type instrumentation \
--results-dir=<RESULTS_DIRECTORY>
```

You can pass additional parameters on the command line, such as the
devices you want to test on. See
[gcloud firebase test android run](https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run).

iOS support for Firebase Test Lab is not yet available, but is planned.
2 changes: 1 addition & 1 deletion packages/e2e/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: e2e
description: Runs tests that use the flutter_test API as integration tests.
version: 0.2.1
version: 0.2.1+1
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e

Expand Down