Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ChromeDriver link #10095

Merged
merged 4 commits into from
Jan 31, 2024
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
14 changes: 7 additions & 7 deletions src/cookbook/testing/integration/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ of an application running on a real device. These tasks are performed
with *integration tests*.

Integration tests are written using the [integration_test][] package, provided
by the SDK.
by the SDK.

In this recipe, learn how to test a counter app. It demonstrates
how to setup integration tests, how to verify specific text is displayed
Expand Down Expand Up @@ -109,7 +109,7 @@ Next, use the `integration_test` and `flutter_test` packages
to write integration tests. Add these dependencies to the `dev_dependencies`
section of the app's `pubspec.yaml` file.

```console
```terminal
$ flutter pub add 'dev:flutter_test:{"sdk":"flutter"}' 'dev:integration_test:{"sdk":"flutter"}'
"flutter_test" is already in "dev_dependencies". Will try to update the constraint.
Resolving dependencies...
Expand Down Expand Up @@ -198,13 +198,13 @@ To test on a real iOS / Android device, first connect the device and run the
following command from the root of the project:

```terminal
flutter test integration_test/app_test.dart
$ flutter test integration_test/app_test.dart
```

Or, you can specify the directory to run all integration tests:

```terminal
flutter test integration_test
$ flutter test integration_test
```

This command runs the app and integration tests on the target device. For more
Expand Down Expand Up @@ -244,13 +244,13 @@ Future<void> main() => integrationDriver();
Launch `chromedriver` as follows:

```terminal
chromedriver --port=4444
$ chromedriver --port=4444
```

From the root of the project, run the following command:

```terminal
flutter drive \
$ flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d chrome
Expand All @@ -266,7 +266,7 @@ flutter drive \
-d web-server
```

[Download ChromeDriver]: https://chromedriver.chromium.org/downloads
[Download ChromeDriver]: https://googlechromelabs.github.io/chrome-for-testing/
[Download EdgeDriver]: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
[Download GeckoDriver]: {{site.github}}/mozilla/geckodriver/releases
[flutter_driver]: {{site.api}}/flutter/flutter_driver/flutter_driver-library.html
Expand Down
55 changes: 27 additions & 28 deletions src/testing/integration-tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description: Learn how to write integration tests
This page describes how to use the [`integration_test`][] package to run
integration tests. Tests written using this package have the following
properties:

* Compatibility with the `flutter drive` command,
for running tests on a physical device or emulator.
* The ability to be run on [Firebase Test Lab][],
Expand All @@ -17,9 +17,9 @@ properties:
enabling tests to be written in a similar style as [widget tests][]

{{site.alert.note}}
The `integration_test` package is part of the Flutter SDK itself.
The `integration_test` package is part of the Flutter SDK itself.
To use it, make sure that you update your app's pubspec file
to include this package as one of your `dev_dependencies`.
to include this package as one of your `dev_dependencies`.
For an example, see the [Project setup](#project-setup) section below.
{{site.alert.end}}

Expand All @@ -46,10 +46,10 @@ the host machine is also the target device.)
**integration_test**

Tests written with the `integration_test` package can:

1. Run directly on the target device, allowing you to test on
multiple Android or iOS devices using Firebase Test Lab.
2. Run using `flutter test integration_test`.
2. Run using `flutter test integration_test`.
3. Use `flutter_test` APIs, making integration tests more
like writing [widget tests][].

Expand Down Expand Up @@ -121,9 +121,8 @@ void main() {
```

{{site.alert.note}}
Note: You should only use `testWidgets`
to declare your tests, or errors won't
be reported correctly.
Only use `testWidgets` to declare your tests.
Otherwise, Flutter could report errors incorrectly.
{{site.alert.end}}

If you are looking for more examples, take a look at the [testing_app][] of
Expand Down Expand Up @@ -152,24 +151,24 @@ These tests can be launched with the
is the optional device ID or pattern displayed
in the output of the `flutter devices` command:

```bash
flutter test integration_test/foo_test.dart -d <DEVICE_ID>
```terminal
$ flutter test integration_test/foo_test.dart -d <DEVICE_ID>
```

This runs the tests in `foo_test.dart`. To run all tests in this directory on
the default device, run:

```
flutter test integration_test
```terminal
$ flutter test integration_test
```

### Running in a browser
### Running in a browser

First, [Download and install ChromeDriver][]
[Download and install ChromeDriver][chromedriver]
and run it on port 4444:

```
chromedriver --port=4444
```terminal
$ chromedriver --port=4444
```

To run tests with `flutter drive`, create a new directory containing a new file,
Expand All @@ -182,7 +181,7 @@ import 'package:integration_test/integration_test_driver.dart';
Future<void> main() => integrationDriver();
```

Then add `IntegrationTestWidgetsFlutterBinding.ensureInitialized()` in your
Then add `IntegrationTestWidgetsFlutterBinding.ensureInitialized()` in your
`integration_test/<name>_test.dart` file:

<?code-excerpt "integration_test/counter_test.dart"?>
Expand Down Expand Up @@ -221,17 +220,17 @@ void main() {

In a separate process, run `flutter_drive`:

```
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/counter_test.dart \
-d web-server
```terminal
$ flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/counter_test.dart \
-d web-server
```

To learn more, see the
[Running Flutter driver tests with web][] wiki page.

## Testing on Firebase Test Lab
## Testing on Firebase Test Lab

You can use the Firebase Test Lab with both Android
and iOS targets.
Expand All @@ -256,13 +255,13 @@ already. Then navigate to **Quality > Test Lab**:

Create an APK using Gradle:

```bash
pushd android
```terminal
$ pushd android
# flutter build generates files in android/ for building the app
flutter build apk
./gradlew app:assembleAndroidTest
./gradlew app:assembleDebug -Ptarget=integration_test/<name>_test.dart
popd
$ popd
```

Where `<name>_test.dart` is the file created in the
Expand All @@ -287,7 +286,7 @@ other tests:
Click **Run a test**,
select the **Instrumentation** test type and drag
the following two files:

* `<flutter_project_directory>/build/app/outputs/apk/debug/<file>.apk`
* `<flutter_project_directory>/build/app/outputs/apk/androidTest/debug/<file>.apk`

Expand Down Expand Up @@ -315,7 +314,7 @@ for instructions on how to upload the .zip file
from the command line.

[Android Device Testing]: {{site.repo.flutter}}/tree/main/packages/integration_test#android-device-testing
[Download and install ChromeDriver]: https://chromedriver.chromium.org/downloads
[chromedriver]: https://googlechromelabs.github.io/chrome-for-testing/
[Firebase Console]: http://console.firebase.google.com/
[Firebase Test Lab]: {{site.firebase}}/docs/test-lab
[Firebase Test Lab section of the README]: {{site.repo.flutter}}/tree/main/packages/integration_test#firebase-test-lab
Expand Down
Loading