Firebase Test Lab

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.

Before you proceed with the steps listed below, make sure that you've completed the native setup guide.

To run the integration tests on Android, you need 2 apps: the app itself (often called the "app under test") and the test intrumentation app.

To build these apps, run:

patrol build android --target integration_test/example_test.dart

Once you have built the apks, use the gcloud tool to run them on Firebase Test Lab:

gcloud firebase test android run \
    --type instrumentation \
    --use-orchestrator \
    --app build/app/outputs/apk/debug/app-debug.apk \
    --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
    --timeout 1m \
    --environment-variables clearPackageData=true \
    --results-bucket=<RESULTS_BUCKET> \
    --results-dir=<RESULTS_DIRECTORY>

You must install the gcloud tool first. Here you can learn more about all available options and flags.

The environment variable clearPackageData=true tells orchestartor to clear the package data between test runs. Keep in mind that it clears only the data of your app, not other data on the device, e.g. Chrome.

It's convenient to create a shell script to avoid typing that long command every time. You might want to take a look at Patrol example app's run_android_testlab script.

On Android, all permissions are granted by default. This behavior can be changed using the alpha version of the gcloud tool.