Firebase Test Lab for Android and Android Studio

Firebase Test Lab for Android provides cloud-based infrastructure for testing Android apps, and features full integration with Android Studio for running instrumented tests and reviewing test results.

This guide describes how to modify instrumented tests in Android Studio for use with Test Lab. For instructions on using Test Lab from the Android Studio UI to create a test matrix, run instrumented tests, and view test results, see Run your tests with Firebase Test Lab.

Capture screenshots

Test Lab provides support for capturing screenshots when running instrumented tests. To learn how to capture screenshots, see Add 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 without writing any test code. You can record your interactions with a device and add assertions to verify UI elements in particular snapshots of your app. Espresso Test Recorder then takes the saved recording and automatically generates a corresponding Espresso UI test that you can run to test your app in Test Lab.

To learn more, see Create UI Tests with Espresso Test Recorder.

Modify instrumented test behavior for Test Lab

Test Lab provides a system variable that you can add to your instrumented tests so that you can cause them to behave differently when you run them in Test Lab than when you run them on your own test device or emulator.

The following code example reads a system property, firebase.test.lab, and sets a string, testLabSetting to true if the test is running in Test Lab. Then, it uses the value of this string to control whether additional statements are executed:

String testLabSetting =
  Settings.System.getString(context.getContentResolver(), "firebase.test.lab");
  if ("true".equals(testLabSetting)) {
    // Do something when running in Test Lab
  }

Şunun hakkında geri bildirim gönderin...

Yardım mı gerekiyor? Destek sayfamızı ziyaret edin.