App Testing agent (Android)

The App Testing agent is a test case generation, management, and execution agent powered by Gemini in Firebase. You define test goals in natural language, and the agent uses AI to understand and navigate your app, simulate user interactions, and provide detailed test results.

How App Testing agent uses your data

App Testing agent is provided by Gemini in Firebase and is governed under the same terms. See How Gemini in Firebase uses your data for more information about how Gemini in Firebase uses your data.

Before you begin

If you haven't already, register your app with Firebase.

If you aren't using any other Firebase products, you only have to create a project and register your app. You don't need to add any SDKs to your app. However, if you decide to use additional products in the future, be sure to complete all of the steps in Add Firebase using the Firebase console.

Create a test case

To run AI-guided tests, the App Testing agent uses your natural language test cases to execute tests against your app.

Each test case is broken down into steps, which will be executed in sequence. Steps allow you to break up your test case into phases, each with their own assertion. The agent may take many actions during any one step.

There are two ways to create a test case: using a YAML file or using the Firebase console. YAML files let you manage the test cases yourself, typically in a versioned source code repository. Alternatively, the Firebase console can store your test cases remotely along with your App Distribution data.

Using YAML files

The following example shows a YAML file that defines two test cases:

tests:
- displayName: Login as guest
  id: login-as-guest
  steps:
  - goal: Log in as a guest
    finalScreenAssertion: The home screen is visible
- displayName: View biography card birth date
  prerequisiteTestCaseId: login-as-guest
  steps:
  - goal: Open the article on "Bob Dylan"
    hint: Use the search function to find it
    finalScreenAssertion: >-
      The article is opened and the title "Bob Dylan" is visible.
  - goal: Find Bob Dylan's birthday in the article
    hint: >-
      Look for the "Born" section in the infobox on the right side of the page.
    finalScreenAssertion: >-
      The text "May 24, 1941" is visible on the screen.

You can organize groups of tests in a single file and separate these test suites in multiple files. You can add a prerequisite test case by adding an ID to the test and then referencing that ID using prerequisiteTestCaseId.

Using the App Distribution console

Alternatively, you can create and manage your test cases in the Firebase Console. To create a test case, open the App Distribution page of the Firebase console and take the following steps:

  1. On the Test Cases tab, click New test case. If you don't want to create your own test case, you can modify or use the provided example test case.
  2. In the Add test case dialog, give the test case a name. This is used to identify the test, but is ignored by the agent.
  3. (Optional) Select a Prerequisite test case that contains set-up steps to run before the main test. If the prerequisite test fails, the entire test will be marked as a failure. Steps and outcomes from the prerequisite and main tests will be shown together in the test results.
  4. Consider breaking your test into multiple steps, by clicking the Add another step button.
  5. Give each step a Goal that describes what the App Testing agent should do during that step.
  6. (Optional) Add a Hint to provide additional information to help the App Testing agent understand and navigate your app during that step.
  7. Add Final screen assertion to help the App Testing agent determine when the step has been successfully completed. This assertion should only refer to what's visible on the screen.
  8. Click Save once you're done customizing your test.

Example test case

The following is an example of how to create a test case using the App Testing agent:

Test title

Home page loads

Goal

Load the home page

Hint

Navigate past any onboarding screens. Dismiss any popups. Don't sign in.

Final screen assertion

The main app home page is visible on screen, all images have loaded, and no errors are displayed.

Run a test

How you run your tests depends on how you create and manage your test cases. If you define test cases using YAML files, you will run those tests using the Firebase CLI. If you create your test cases in the App Distribution console, you will run them from the console or through one of the App Distribution CLI tools.

Using YAML files

Test cases defined in YAML files can be executed using the Firebase CLI.

  1. Install or update to the latest version of the Firebase CLI. We recommend downloading the standalone binary for the CLI specific to your OS.
  2. Sign in and test that you can access your projects. Note that if you're using the Firebase CLI in a CI environment, you can also authenticate with a service account or by using login:ci.
  3. Run the apptesting:execute command. For example:

    firebase apptesting:execute \
      --app=1:1234567890:android:0a1b2c3d4e5f67890 \
      --test-dir=./mytests \
      ./app/build/outputs/apk/debug/app-debug.apk
    
apptesting:execute [options] [/path/to/app/binary]
--app

Required: Your app's Firebase App ID. You can find the App ID in the Firebase console, on the General Settings page.

--app 1:1234567890:android:0a1b2c3d4e5f67890

--test-dir

Path to a directory that contains test case YAML files. The command will search recursively under this directory, so the files can optionally be organized into subdirectories. If unset, "./tests" is used by default.

--test-devices or
--test-devices-file

The test devices you want to distribute builds to the App Testing agent feature.

You can specify the test devices as a semicolon-separated list of test devices:

--test-devices "model=tokay,version=36,locale=en,orientation=portrait;model=b0q,version=33,locale=en,orientation=portrait"

Or, you can specify the path to a plain text file containing a semicolon-separated list of test devices:

--test-devices-file "/path/to/test-devices.txt"

You can look up the available device models using the gcloud CLI.

--test-non-blocking

If set, the command will start the tests and then return immediately instead of waiting for them to complete.

--test-file-pattern

A regular expression pattern. Only tests contained in files that match this pattern will be executed.

--test-name-pattern

A regular expression pattern. Only tests with display names that match this pattern will be executed.

/path/to/app/binary

Optional: The path to your app's binary. If omitted, the agent will use the last release uploaded to App Distribution for the specified app.

Using the App Distribution console

To run test cases stored in App Distribution, you can use the Firebase console, the Firebase CLI, or App Distribution's Gradle or fastlane plugins.

Import & export test cases with YAML files

Importing test cases from YAML files is useful when you want to manage test cases outside of the Firebase console. It can also be useful to export test cases to move them between projects. You can use an LLM to refine existing test cases or create new test cases. You can import and export test cases from the Test Cases page in the Firebase console or programmatically using the Firebase CLI. For an example of a YAML test case, see Create a YAML test case.

View your test results

You can view the results of your tests from the Releases page in the App Testing agent tab of a release. The View details button will open the Test Results dialog and show you any issues, screenshots of the app, and the actions that Gemini took during the test.

If a test includes replayed actions, you can view the original AI-guided test run or clear the cache.

To learn more about your test results, use the following table:

Icon Name Description
spark AI action Indicates that the App Testing agent used Gemini to decide to take an action or end the step.
replay Replayed action Indicates that the App Testing agent replayed an action from a previous successful run of the test.
spark AI assertion Indicates that the App Testing agent used Gemini to validate a final screen assertion, after replaying actions from a previous successful run of the same test.

Debug your test results

If your test results are different from what you expected, you can debug your test using the Show agent view toggle under View details on the Test Results page. The agent view shows you the on screen elements that the App Testing agent was able to detect when using the app's accessibility information. If you would like to take a closer look at what the agent saw, you can download that information from the action overflow menu.

You can also use the View artifacts button on the Test Results page to look at all of the videos, logs, and other Cloud artifacts for your test results.

Known issues and limitations

The App Testing agent preview has some known limitations:

  • Because the App Testing agent uses generative AI to test your app, it will sometimes take different actions while still following the same instructions.
  • The App Testing agent only supports the following actions: tap, enter text, swipe up/down/left/right, long press, drag-and-drop, back, and wait.
  • The App Testing agent has trouble executing tests containing only a single step that takes many actions to accomplish. It performs better when complex tasks are broken up into multiple shorter steps.
  • The App Testing agent sometimes won't scroll to expose other elements off screen. This happens more often when there is no visual indication of scrollability. As a workaround, the "hints" field can be used to suggest scrolling.
  • The App Testing agent sometimes has trouble counting, for example performing an action a specific number of times.
  • The App Testing agent cannot navigate your app if FLAG_SECURE is enabled. Instead of screenshots of your app, it will only see a blank screen.

Testing quotas

During the preview, the AI-guided tests will be offered at no cost within a quota limit. The default quota limit is 200 tests per month, per Firebase project.

Note that if you choose to run multiple test cases, or run the same test case, on multiple devices, this counts as multiple tests. For example, if you run 2 test cases on 2 devices, this counts as a total of 4 tests.

To increase your quota above the default limit, contact Firebase Support with your use case.