Search code examples
androidfirebaseunit-testingfirebase-remote-configandroid-mvp

Firebase remote config Unit Test in Android MVP?


Is there any example about unit test of firebase remote config in android?

Below code in our presenter and we want to write unit test for it. And why there is no enough source about unit test?

@Override
public void fetchFirebaseRemoteConfig() {

    firebaseRemoteConfig.setConfigSettings(new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG).build());
    firebaseRemoteConfig.fetch(BuildConfig.DEBUG ? 0 : TimeUnit.HOURS.toSeconds(12)).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {

            if(task.isSuccessful()) {
                Log.i(LogTags.FIREBASE_REMOTE_CONFIG, Constant.SUCCESS);
                firebaseRemoteConfig.activateFetched();
            } else {
                Log.i(LogTags.FIREBASE_REMOTE_CONFIG, Constant.FAILURE);
            }

            getMvpView().onFirebaseFetched();
        }
    });
}

Solution

  • We decide to not write an Unit Test for Firebase Remote Config. Because Firebase has proguard and we can not mock Firebase Remote Config.

    If you have any other suggestions feel free to discuss