Firebase Android libraries exercise all three types of tests recommended by the
Android Testing Pyramid.
Depending on the requirements of the specific project, some or all of these
tests may be used to support changes.
These are tests that run on your machine's local Java Virtual Machine (JVM). At
runtime, these tests are executed against a modified version of android.jar
where all final modifiers have been stripped off. This lets us sandbox behaviors
at desired places and use popular mocking libraries.
Unit tests can be executed on the command line by running
These are tests that run on a hardware device or emulator. These tests have
access to Instrumentation APIs, give you access to information such as the
In Firebase, instrumentation tests are used at different capacities by different
projects. Some tests may exercise device capabilities, while stubbing any calls
to the backend, while some others may call out to nightly backend builds to
ensure distributed API compatibility.
Along with Espresso, they are also used to test projects that have UI
Before you can run integration tests, you need to add a
file to the root of your checkout. You can use the
any project that includes an Android App, though you'll likely want one that's
separate from any production data you have because our tests write random data.
If you don't have a suitable testing project already:
- Open the Firebase console
- If you don't yet have a project you want to use for testing, create one.
- Add an Android app to the project
- Give the app any package name you like.
- Download the resulting
google-services.json file and put it in the root of
Running Integration Tests
Integration tests can be executed on the command line by running