Automating Android App Testing with Robo

In Firebase Test Lab, you use real and virtual devices to test your app. These devices run in a Google data centre. They contain the latest APIs, and have customizable locale settings, enabling you to test your app as people around the world would use it.

You can let Test Lab test your app for you, which is called Robo Testing, or you can create Espresso instrumentation tests in Android Studio and have Test Lab run them.

We'll look at both of these in more detail shortly. You can also run Robo Tests from the Google Play console pre-launch report each time you upload an app to the closed or open test tracks.

The pre-launch report offers the same Robo Test features as Firebase Test Lab. The benefit of Test Lab comes from being able to run tests on a wider range of devices, with more options, as well as to be able to run your own instrumentation tests.

Firebase Test Lab

Let's take a close look at Robo Tests. When you run a Robo Test, an application crawler analyses the structure of your app's UI, and then explores it methodically, simulating user activity.

Robo Tests capture log files, performance data, screenshots of unique screens as well as annotated video to show you the simulated user actions it performed.

These logs and performance data and screenshots and videos can help you determine the cause of crashes and find issues with your app's UI.

You can also use Robo Tests to validate bug fixes and test for regressions. This is because Robo Testing simulates the same user activities in the same order each time it tests your app.

There is also an option to control Robo Tests. For example, you may want to test a common user journey or start the crawler at a specific screen. You do this using a Robo Script. You create these scripts in Android Studio, simply select Firebase from the tools menu, then click Record Robo Script, and use it to guide Robo Test.

Now record and upload your scripts to Firebase Test Lab. In addition to a regular crawl from the beginning of your app, you can test up to three deep links.

Here, the crawler follows the link and then exercises your app for an additional 30 seconds, reporting on anything it finds in the same way as it does for the remaining tests.

Robo Test can also sign into your app, using either a Google login or your own custom log in credentials.

Robo Tests are a great way to get started with app testing with minimal effort on your part. However, for a truly high-quality app, you will almost certainly need to create your own instrumentation test, which Firebase Test Lab can then run for you.

Espresso Test

You can create these test scripts in Android Studio, either manually or you can record them using Record Espresso Test on the Run menu. You record your test script by interacting with your app, when done, saving your test script locally.

To get the most out of Espresso Test, the key is to modularize your tests, creating test snippets for the functions used in the majority of your tests, such as logging in or filling out a search form.

You can then invoke these snippets from your test scripts whenever you need these common functions, then as you update your app, use Espresso Test Recorder to quickly re-record the snippets where there have been changes.

You can then run these test scripts locally or load the suite of tests into your continuous integration server and get the assurance that you haven't broken your app at each update.

Of course, you can upload the test scripts to Firebase Test Lab. You can then choose to run the test on a selection of over 50 virtual and physical devices, many of them available with a range of Android versions.

Other options include testing your app in different languages or screen orientations and more. You can also run your test in Firebase Test Lab from your continuous integration server.

Espresso Test Recorder enables you to quickly and easily create tests for all parts of your app. You can then use the features of a continuous integration server, the pre-launch report and Firebase Test Lab to automate your testing, improving your app quality while freeing your time to focus on development.