Google Firebase Test Lab is a cloud-based app-testing infrastructure. With one operation, you can test your Android or iOS app across a wide variety of devices and device configurations, and see the results-including logs, videos, and screenshots-in the Firebase console.
Firebase Test Lab runs Espresso and UI Automator 2.0 tests on Android apps, and XCTest tests on iOS apps. Write tests using one of those frameworks, then run them through the Firebase console or the gcloud command line interface.
Firebase Test Lab lets you run the following types of tests:
- Instrumentation test: A test you write that allows you to drive the UI of your app with the actions you specify. An instrumentation test can also make explicit assertions about the state of your app to verify correct functionality using AndroidJUnitRunner APIs. Test Lab supports Espresso and UI Automator 2.0 instrumentation test frameworks.
- Robo test: A test that analyses your app’s interface and then explores it automatically by simulating user activities.
- Game loop test: A test that uses a “demo mode” to simulate player actions in game apps.
How do I validate the Visual UI in Multiple Devices?
As with all web and mobile applications. Applitools offers an easy, consistent way to collect visual data from multiple device types running different viewport sizes. In the rest of this article, you will run through a demonstration for using Applitools with Google Firebase Test Lab.
In this Demo I have choose a simple “Hello World” app, and to keep you running we already have an example Espresso Instrumentation Test you can find the Complete Project here https://github.com/applitools/eyes-android-hello-world
I know you have looked into the GitHub repo. Let’s just get few more prerequisites installed and make sure they are ready to use and deep dive. Make sure you have installed and/or configured the following:
- Java Installed
- JAVA_HOME environment variable is set to the Java SDK path
- Android Studio IDE
Installing the Android Studio
Now let’s install Android Studio / SDK so that you can run the test script on an emulator or real device. You could install the Android SDK only but then you have to do additional advanced steps to properly configure the Android environment on your computer. I highly recommend installing the Android Studio as it makes your life easier.
Download the Android Studio executable. Follow the steps below to install locally on your computer:
Run the Visual UI Test locally
1. Get the code:
- Option 1: git clone https://github.com/applitools/eyes-android-hello-world
- Option 2: Download it as a Zip file and unzip it.
2. Import the project into Android Studio
Let’s look at the Instrumented test ExampleInstrumentedTest under androidTest.
Before we run the test on Firebase lets run it on local emulator.
- Configure a local device Emulator from the AVD Manager in your android studio
- Insert Your Applitools API KEY in the test
- Launch the SimpleTest () from the ExampleInstrumentedTest.java. This will launch the Instrumentation test in the emulator.
That’s pretty easy isn’t it? Applitools will now capture each screen where the eyes.CheckWindow() is called and create a baseline on the first run.
Once the test completes, you can analyze the test results on the Applitools dashboard.
Now let’s run the test on Firebase devices. To do this we need first need an account so let’s get that
Step1: Navigate to https://firebase.google.com/ and click on sign in
Step2: Click on Go to Console, Navigates to the Console Dashboard
Step3: Create a Project, once you create a project, all good to explore the dashboard and see through all the features available here.
Step 4: Lets Add the Configurations in android studio to run the tests
- Click on Run and select the edit configurations.
- Click on the + button to create a new android launch/debug configuration based on templates.
- Select the Android Instrumentation Tests > In the Module select app >
Test as Class > com.applitools.helloworld.android.ExampleInstrumentedTest
- Now in the Deployment Target Options select Firebase Test lab Device Matrix
Step 5: Sign in with Google Firebase account and click ok
Step 6: Re-open the edit configurations
Now you can see the configure settings for Matrix configuration and cloud project
Select your project and add one or more custom devices from list of 150. For now let’s add 2 devices, Platform Android 9.x, API Level 28 (pie), Locale, Orientation.
We will use these devices to run our Instrumentation test on Firebase.
That’s it we are all good to run our test on the Firebase
Click on Run Example Instrumented Test this will now execute you tests on the devices you have selected on Firebase.
Let’s Go back to The Test lab on Firebase and you can see your tests running over there Parallelly with visual comparison checks done on Applitools AI Platform.
Applitools allows you to test your mobile app by running it on any device lab. Google Firebase allows a streamline platform for developers (build) and quality engineers (test) to run tests on any device configuration. The integration make it easier to use the best of platforms for best quality applications.
For More Information
Originally published at https://applitools.com on September 1, 2020.