Run tests with Android Studio Stay organized with collections Save and categorize content based on your preferences.
Firebase Test Lab provides cloud-based infrastructure for testing Androidapps, and features full integration with Android Studio for runninginstrumented tests and reviewing test results.
This guide describes how to modify instrumented tests in Android Studio so youcan integrate and run them withTest Lab. For instructions on usingTest Lab from the Android Studio UI to create a test matrix, run aninstrumented test, and view the test results, seeRun your tests withFirebase Test Lab.
Capture screenshots
Test Lab provides support for capturing screenshots when runninginstrumented tests. To learn how to capture screenshots, seeAdd the screenshot library to your project.
Create tests using Espresso Test Recorder
The Espresso Test Recorder tool lets you create UI tests for your app withoutwriting any test code. You can record your interactions with a device and addassertions to verify UI elements in particular snapshots of your app. EspressoTest Recorder then takes the saved recording and automatically generates acorresponding Espresso UI test that you can run to test your app inTest Lab.
To learn more, seeCreate UI Tests with Espresso Test Recorder.
Modify instrumented test behavior forTest Lab
Test Lab provides a system variable that you can add to your instrumentedtests so that you can cause them to behave differently when you run them inTest Lab than when you run them on your own test device or emulator.
The following code example reads a system property,firebase.test.lab, andsets a string,testLabSetting totrue if the test is running inTest Lab.Then, it uses the value of this string to control whether additional statementsare executed:
Kotlin
valtestLabSetting=Settings.System.getString(contentResolver,"firebase.test.lab")if("true"==testLabSetting){// Do something when running in Test Lab// ...}
Java
StringtestLabSetting=Settings.System.getString(getContentResolver(),"firebase.test.lab");if("true".equals(testLabSetting)){// Do something when running in Test Lab// ...}
Use Gradle Managed Devices via theFirebase Test Lab plugin
Gradle Managed Devices via theFirebase Test Labplugin lets you run automated instrumented tests at scale onTest Labdevices, based on the configurations in your project's Gradle files.
Gradle Managed Devices also offer smart sharding, which lets you distributetests optimally across shards based on your previous test history. With smartsharding, shards run for approximately the same length of time and return testresults as quickly as possible. Smart sharding lets you run large test suites inparallel, making this feature well suited for CI/CD flows.
To enable smart sharding using theGradle Managed DevicesTest Lab plugin,follow the instructions inOptimize test runs with smartsharding .
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-17 UTC.