diff --git a/src/content/cookbook/testing/integration/introduction.md b/src/content/cookbook/testing/integration/introduction.md index fb5265ba7f3..2054875fbea 100644 --- a/src/content/cookbook/testing/integration/introduction.md +++ b/src/content/cookbook/testing/integration/introduction.md @@ -16,7 +16,25 @@ To perform these tasks, use *integration tests*. Integration tests verify the behavior of the complete app. This test can also be called end-to-end testing or GUI testing. -The Flutter SDK includes the [integration_test][] package. +## Testing frameworks + +Flutter supports two main approaches for integration testing: + +### `integration_test` package + +The Flutter SDK includes the [`integration_test`][integration_test] package. +Tests written with `integration_test` can perform the following tasks: + +* Run on the target device. + To test multiple Android or iOS devices, use Firebase Test Lab. +* Run from the host machine with `flutter test integration_test`. +* Use `flutter_test` APIs. This makes integration tests + similar to writing [widget tests][]. + +However, `integration_test` can't interact with native platform UI, +such as permission dialogs, notifications, or the contents of +platform views. For these additional features, consider using the +[`patrol`][] package. ## Terminology @@ -30,22 +48,15 @@ The Flutter SDK includes the [integration_test][] package. If you run your app in a web browser or as a desktop application, the host machine and the target device are the same. -## Dependent package +## Getting started -To run integration tests, add the `integration_test` package -as a dependency for your Flutter app test file. +To use `integration_test`, add it as a dependency for your +Flutter app test file. To migrate existing projects that use `flutter_driver`, consult the [Migrating from flutter_driver][] guide. -Tests written with the `integration_test` package -can perform the following tasks. - -* Run on the target device. - To test multiple Android or iOS devices, use Firebase Test Lab. -* Run from the host machine with `flutter test integration_test`. -* Use `flutter_test` APIs. This makes integration tests - similar to writing [widget tests][]. +To use `patrol`, follow the [Patrol setup guide][]. ## Use cases for integration testing @@ -53,7 +64,9 @@ The other guides in this section explain how to use integration tests to validat [functionality][] and [performance][]. [functionality]: /testing/integration-tests/ -[performance]: /cookbook/testing/integration/profiling/ [integration_test]: {{site.repo.flutter}}/tree/main/packages/integration_test [Migrating from flutter_driver]: /release/breaking-changes/flutter-driver-migration +[`patrol`]: {{site.pub-pkg}}/patrol +[Patrol setup guide]: https://patrol.leancode.co/getting-started +[performance]: /cookbook/testing/integration/profiling/ [widget tests]: /testing/overview#widget-tests diff --git a/src/content/testing/overview.md b/src/content/testing/overview.md index 771aa0ea56e..da9d2506b34 100644 --- a/src/content/testing/overview.md +++ b/src/content/testing/overview.md @@ -96,12 +96,24 @@ such as iOS Simulator or Android Emulator. The app under test is typically isolated from the test driver code to avoid skewing the results. +The Flutter SDK includes the [`integration_test`][] package. +However, this package can't interact with native platform UI, +such as permission dialogs, notifications, or platform views. +For apps that need native interactions, you can use the +[`patrol`][] package, an open-source framework that extends +Flutter's testing capabilities with native platform support. + For more information on how to write integration tests, see the [integration testing page][]. +[`integration_test`]: {{site.repo.flutter}}/tree/main/packages/integration_test +[`patrol`]: {{site.pub-pkg}}/patrol + ### Recipes {:.no_toc} - [Integration testing concepts](/cookbook/testing/integration/introduction) +- [Write and run a Flutter integration test](/testing/integration-tests) +- [Write and run a Patrol integration test](https://patrol.leancode.co/documentation/write-your-first-test) - [Measure performance with an integration test](/cookbook/testing/integration/profiling) ## Continuous integration services @@ -119,13 +131,15 @@ integration services, see the following: * [Test Flutter apps on Travis][] * [Test Flutter apps on Cirrus][] * [Codemagic CI/CD for Flutter][] +* [Codemagic CI/CD for Patrol][] * [Flutter CI/CD with Bitrise][] [code coverage]: https://en.wikipedia.org/wiki/Code_coverage [Codemagic CI/CD for Flutter]: https://blog.codemagic.io/getting-started-with-codemagic/ +[Codemagic CI/CD for Patrol]: https://docs.codemagic.io/integrations/patrol-integration/ [Continuous delivery using fastlane with Flutter]: /deployment/cd#fastlane [Flutter CI/CD with Bitrise]: https://devcenter.bitrise.io/en/getting-started/quick-start-guides/getting-started-with-flutter-apps [Test Flutter apps on Appcircle]: https://blog.appcircle.io/article/flutter-ci-cd-github-ios-android-web# [Test Flutter apps on Cirrus]: https://cirrus-ci.org/examples/#flutter [Test Flutter apps on Travis]: {{site.flutter-blog}}/test-flutter-apps-on-travis-3fd5142ecd8c -[integration testing page]: /testing/integration-tests +[integration testing page]: /cookbook/testing/integration/introduction diff --git a/src/content/testing/testing-plugins.md b/src/content/testing/testing-plugins.md index fe2a32956c5..dac55ceec1e 100644 --- a/src/content/testing/testing-plugins.md +++ b/src/content/testing/testing-plugins.md @@ -42,8 +42,10 @@ and look in the indicated directories. code that needs to run in a browser. These are often the most important tests for a plugin. - However, Dart integration tests can't interact with native UI, - such as native dialogs or the contents of platform views. + However, Dart integration tests using `integration_test` can't + interact with native UI, such as native dialogs or the contents + of platform views. For native component interaction support, + consider using [`patrol`][] See the `example/integration_test` directory for an example. @@ -85,12 +87,12 @@ enables tests that interact with both native and Flutter UI elements, so can be useful if your plugin can't be tested without native UI interactions. - [Espresso]: {{site.repo.packages}}/tree/main/packages/espresso [GoogleTest]: {{site.github}}/google/googletest [integration tests]: /cookbook/testing/integration/introduction [JUnit]: {{site.github}}/junit-team/junit4/wiki/Getting-started [mocked in tests]: /testing/plugins-in-tests#mock-the-platform-channel +[`patrol`]: {{site.pub-pkg}}/patrol [plugin-tests]: /packages-and-plugins/developing-packages#step-1-create-the-package-1 [unit tests]: /cookbook/testing/unit/introduction [widget tests]: /cookbook/testing/widget/introduction @@ -190,10 +192,11 @@ Some extra considerations for plugin testing: try to have at least one integration test of each platform channel call. -* If some flows can't be tested using integration - tests—for example if they require interacting with - native UI or mocking device state—consider writing - "end to end" tests of the two halves using unit tests: +* If some flows can't be tested using the `integration_test` package-for + example if they require interacting with native UI or mocking + device state-consider using the [`patrol`][] package for + native UI interactions, or writing "end to end" tests of the two halves + using unit tests: * Native unit tests that set up the necessary mocks, then call into the method channel entry point