androidfirebaseautomated-testsandroid-espressofirebase-tools

How to synchronize Python scripts and Espresso tests for E2E testing with Firebase Realtime Database?


I have developed an Android app that integrates with Firebase Firestore and Realtime Database. I now want to perform End-to-End (E2E) tests that involve Firebase.

Test Setup:

The goal is to synchronize the Python script with the Espresso tests:

  1. The Python script updates the data in the Firebase Realtime Database.
  2. Afterward, a specific Espresso test verifies whether the app correctly reflects the updated data.
  3. The Python script then updates the Realtime Database again, and a different Espresso test validates the new changes.

I want to ensure that the updates and tests run in sync.

Are there any test frameworks that facilitate synchronisation between Python scripts and Espresso tests? Alternatively, what approaches or tools can help achieve this synchronisation effectively?

I am already using Mockk to mock Firebase for component tests. However, for E2E tests, I do not want to mock the Firebase database as I need to test real delays and avoid adding complexity to the mock objects.

Any insights or recommendations are appreciated!


Solution

  • My solution: I created a Flask server that acts as an interface between the Android Emulator and the Firebase Emulator.

    Before (@BeforeClass) the tests I use OkHttp3 to send HTTP requests from the tests to the Flask server. These requests specify the data I want to load into Firebase. When the Flash server receives a request, it uses the Firebase Admin SDK to upload the data.