we are using the new version of FlutterFire, but we have some issues when running our tests, we managed to initialise Firebase adding this:
setUp(() async {
TestWidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
});
But now we have this error message:
MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
package:flutter/src/services/platform_channel.dart 159:7 MethodChannel._invokeMethod
The app runs well both on iOS and Android, we only have the issue when running the widget tests. We've tried with Flutter stable and dev channels.
I'm assuming you are performing either unit or widget testing. Just take a look at how the plugin itself is being tested.
class FakeFirebaseAppPlatform extends Fake implements FirebaseAppPlatform {}
They just fake the object.
Why? because this plugin is implemented using method channels and while testing you don't have access to the native platform .Your only option is to mock or fake your interactions with Firebase either:
As the authors of the plugin are doing using Mockito
Mock the method channel as illustrated in this answer , (which is in my opinion more cumbersome, and best suited if you are developing a plugin yourself)