Skip to content

Testing Guide

Oskar Zanota edited this page Nov 25, 2024 · 4 revisions

TearDown

All tests should extend the TearDown class, like so:

class MyTest : TearDown() {

When extending this class, state is automatically cleaned up between tests. If needed, you can override the tearDown method but make sure to call its super-implementation.

Tests using FirestoreReferenceList

For tests calling FirestoreReferenceList.requestAll(), it is crucial to make a static mock of Firebase.firestore. Otherwise, the end to end tests will fail because the .requestAll acts as a Firebase initialisation, preventing the end to end tests from reinitialising the Firebase instance with the local emulator.

3. Adding AuthStateListeners

Firebase’s AuthStateListeners persist between tests. In order to remove them between tests, any listener must be registered like so:

Firebase.auth.registerAuthStateListener { ... }

And not the previous .addAuthStateListener.

Clone this wiki locally