Integrations - Browserstack
Overview
Browserstack App Automate is a popular cloud device farm.
This integration is currently Android-only.
Change runner
Modify the app-level build.gradle:
android/app/build.gradle
android {
// ...
defaultConfig {
//...
testInstrumentationRunner "pl.leancode.patrol.BrowserstackPatrolJUnitRunner"
}
// ...
}
// ...
That's all!
Upload to Browserstack
To run Android UI tests on BrowserStack:
- Build the app under test and the instrumentation app (see docs)
- Upload the app under test APK to Browserstack (see docs)
- Upload the instrumentation app APK to Browserstack (see docs)
- Start test execution on Browserstack (see docs)
You can do it all manually, but we recommend using the bs_android script to
speed up this process. bs_android
is part of LeanCode's mobile-tools. If
you're using Homebrew, you can install it with:
brew tap leancodepl/tools
brew install mobile-tools
The bs_android
script requires the BROWSERSTACK_CREDS
environment variable
to be set so it can authenticate with Browserstack:
export YOUR_USERNAME:YOUR_ACCESS_KEY
Get your username and access on Browserstack's account page.
Now reload your shell (e.g. exec zsh
) and run bs_android
:
$ export BROWSERSTACK_PROJECT=AwesomeApp # optional
$ export BROWSERSTACK_DEVICES="[\"Google Pixel 4-10.0\"]" # optional
$ bs_android
• Building apk with entrypoint test_bundle.dart...
✓ Completed building apk with entrypoint test_bundle.dart (11.0s)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 87.4M 100 235 100 87.4M 7 2857k 0:00:33 0:00:31 0:00:02 2052k
Uploaded app, url: bs://fb61a714e1a0c60e2578d940dad52b74da244d54
Uploaded test, url: bs://a715b1231d41ac627bd683f1b16c28476babd72e
{"message":"Success","build_id":"a30440db559fcab65554ab0273437f3bd45d761b"}
Scheduled test execution
bs_android
forwards all its options and flags to patrol build
:
bs_android \
--target integration_test/example_test.dart,integration_test/another_test.dart \
--release \
--dart-define 'KEY_EXAMPLE=VALUE_EXAMPLE'