HOW TO INTEGRATE FIREBASE TEST LAB TO THE MOBILE CI/CD PIPELINE FOR ANDROID
Published: 2021-09-08 16:20:30

<a href="https://appcircle.io/blog/how-firebase-test-lab-ci-cd-android-apps/" link rel="canonical" ><img src="https://appcircle.io/wp-content/uploads/2020/07/Using-Firebase-Test-Lab-for-Continuous-Testing-845x321.png.webp"></a>

Reading Time: 4 minutes

Appcircle is a mobile CI/CD platform that provides a fully automated environment to manage mobile app CI, CD and CT (continuous testing).

For continuous testing, you have a number of options with Appcircle and you can use Firebase Test Lab for multiple-device testing. In this article, we will be integrating Firebase Test Lab to your mobile CI/CD workflow in a few easy steps.

Manage your mobile CI, CD and CT (continuous testing) with Appcircle

[Start for Free](https://appcircle.io/start)

Setting Up a Firebase Project and a Service Account
---------------------------------------------------

To start with the [Firebase Test Lab](https://firebase.google.com/products/test-lab), you need to have an associated Firebase Project, which is created in the [Firebase console](https://console.firebase.google.com/). Go to the console, press the "Add Project" button and specify the project name and the other settings:

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-1.png.webp)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-1.png)

After your project is created, go to the [Google Cloud Platform console](https://console.cloud.google.com/iam-admin/serviceaccounts/) to create a service account. Press the "Create Service Account" button and follow the prompts to create a service account with the Editor role:

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-2.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-2.png)

Once the service account is created, click on the three dot menu next to the service account and press "Create Key".

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-3.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-3.png)

Select the key format as "JSON" and download the created key. We will be using this key for Appcircle to be able to deploy apps to Firebase Test Lab.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-4.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-4.png)

As the final step, go to the [Google Developers Console API Library page](https://console.developers.google.com/apis/library) and find and enable the following APIs:

-   Google Cloud Testing API
-   Cloud Tool Results API

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-5.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-5.png)

Firebase Test Lab Authentication Configuration in Appcircle
-----------------------------------------------------------

To start, go to the environment variables section and add the service account JSON key created in the previous step as a [new environment variable](https://docs.appcircle.io/environment-variables/managing-variables#create-environment-variable-groups-and-add-key-value-pairs). Take a note of the variable name, which will be necessary in the workflow configuration.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-6.png.webp)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-6.png)

Then [select the related environment variable group](https://docs.appcircle.io/environment-variables/managing-variables#use-environment-variable-groups-in-builds) in the build configuration of the project that will be using Firebase Test Lab.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-7.png.webp)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-7.png)

Build Workflow Configuration for Firebase Test Lab
--------------------------------------------------

To utilize Firebase Test Lab in your builds, open the [workflow editor](https://docs.appcircle.io/workflows/why-to-use-workflows) and add the "Firebase Test Lab for Android" step after the build or sign steps. If you want to run instrumentation tests, also add the "Android Build for UI Testing" step before the Firebase Test Lab step.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-8.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-8.png)

If you want to use the UI Test Build output or the Signed Build output in Firebase Test Lab, add any of these steps before the Firebase Test Lab step and take a note of the output path of these steps. You will need this environment variable for testing configuration.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-9.png.webp)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-9.png)

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-10.png.webp)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-10.png)

Before the build, the last task is to configure the Firebase Test Lab for Android step:

-   Project ID: Enter the name of the Firebase project created
-   Key File: Enter the name of the key file uploaded as an environment variable ($ is required before the key name).
-   Test Type: Select a test type. robo and instrumentation are supported.
-   Bucket Name: Enter a bucket name to store the test results in a Google Cloud Storage bucket.
-   APK Path: The default value is the APK produced by the "Android Build" step. You can specify a different environment variable to use the APK files produced in other steps.
-   Test APK Path: Specify the environment variable to the path of the APK build for UI testing
-   Extra Arguments: For further configuration of the test run. Please refer to the [Google Cloud CLI Documentation](https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run).

Once everything is set up, press save to save your step configuration. Then you can configure and run your build just like any other app.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-11.png.webp)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-11.png)

Viewing the Firebase Test Lab Step Results
------------------------------------------

Once your build is done, you can view the results of the Firebase Test Lab step in the build logs.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-12.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-12.png)

The full details of the tests are accessible in the [Firebase console](https://console.firebase.google.com/) and in your Google Cloud Storage bucket for analysis.

[![](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-13.png)](https://appcircle.io/wp-content/uploads/2020/07/Firebase-Test-Lab-Appcircle-13.png)

With Appcircle, you can automate the full lifecycle of your mobile app with continuous integration, continuous delivery and continuous testing.

[Start Using Appcircle Now](https://appcircle.io/start)