From 816432296e3b028a0f5174f2693e781f2d3eacb5 Mon Sep 17 00:00:00 2001 From: Anthony Sansone Date: Tue, 30 Jan 2024 22:50:16 -0600 Subject: [PATCH] Updated ChromeDriver link (#10095) Updated ChromeDriver link. Includes some extra code block lexer updates. Fixes #10029 --- .../testing/integration/introduction.md | 14 ++--- src/testing/integration-tests/index.md | 55 +++++++++---------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/cookbook/testing/integration/introduction.md b/src/cookbook/testing/integration/introduction.md index 1447a60e41..ebb8f23d0e 100644 --- a/src/cookbook/testing/integration/introduction.md +++ b/src/cookbook/testing/integration/introduction.md @@ -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 @@ -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... @@ -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 @@ -244,13 +244,13 @@ Future 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 @@ -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 diff --git a/src/testing/integration-tests/index.md b/src/testing/integration-tests/index.md index 02d95d5f14..4ec513ab45 100644 --- a/src/testing/integration-tests/index.md +++ b/src/testing/integration-tests/index.md @@ -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][], @@ -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}} @@ -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][]. @@ -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 @@ -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 +```terminal +$ flutter test integration_test/foo_test.dart -d ``` 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, @@ -182,7 +181,7 @@ import 'package:integration_test/integration_test_driver.dart'; Future main() => integrationDriver(); ``` -Then add `IntegrationTestWidgetsFlutterBinding.ensureInitialized()` in your +Then add `IntegrationTestWidgetsFlutterBinding.ensureInitialized()` in your `integration_test/_test.dart` file: @@ -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. @@ -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/_test.dart -popd +$ popd ``` Where `_test.dart` is the file created in the @@ -287,7 +286,7 @@ other tests: Click **Run a test**, select the **Instrumentation** test type and drag the following two files: - + * `/build/app/outputs/apk/debug/.apk` * `/build/app/outputs/apk/androidTest/debug/.apk` @@ -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