Having tests doesn't bring you any benefits if you don't automatically verify
that they pass. We know this too well, so we've put a lot of work into making it
easy to run Patrol tests in a multitude of ways, so you can choose whatever
suits you best.
Before you proceed with the steps listed below, make sure that you've
completed the native setup guide.
There are many device lab providers. Below we're showing how to run Patrol tests
on Firebase Test Lab, because it's popular in the Flutter community, but the
instructions should be similar for other device farms, such as AWS Device
Farm or BrowserStack.
To run the integration tests on Android, you need 2 apps:
the normal apk (often called the "app under test"). To build it, run:
You need to run the above commands from the android directory of your
Flutter project.
Once you have built the apks, use the gcloud tool to run them on Firebase
Test Lab:
gcloud firebase test android run --type instrumentation \ --app build/app/outputs/apk/debug/app-debug.apk \ --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \ --timeout 1m \ --results-bucket=<RESULTS_BUCKET> \ --results-dir=<RESULTS_DIRECTORY>
It can be convenient to write a utility shell script to automate this process
instead of having to enter these long commands every time you want to run
tests. In such case, you might want to take a look at Patrol example app's
run_android_testlab script.
First, build your Flutter app, choosing the integration test file as target:
flutter build ios --target integration_test/example_test.dart --debug # or --release
Then, build the UI testing target by running xcodebuild in the ios
directory:
Now, go to your project's root directory, and from there go to the build
outputs:
cd build/ios_integ/Build/Products
Create a zip archive named ios_test.zip. It will contain both your app
under test (Runner target) and UI test runner (RunnerUITests target).
zip -r "ios_tests.zip" "Release-iphoneos" "Runner_iphoneos15.7-arm64.xctestrun"
And finally, upload the ios_test.zip to Firebase Test Lab for execution:
exec gcloud firebase test ios run \ --test "build/ios_integ/Build/Products/ios_tests.zip" \ --device model=iphone8,version=15.7,locale=en_US,orientation=portrait
If your .xctestrun file has different iOS version in its name than the
device you're running on, simply rename the .xctestrun so that the version
will match.
It can be convenient to write a utility shell script to automate this process
instead of having to enter these long commands every time you want to run
tests. In such case, you might want to take a look at Patrol example app's
run_ios_testlab script.