New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running Test throws MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core #3311
Comments
The error "MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)" points towards your Dart code being updated, but your native code hasn't updated. Can you try running |
I have already tried that!
mån 24 aug. 2020 kl. 11:43 skrev Elliot Hesp <notifications@github.com>:
The error "MissingPluginException(No implementation found for method
Firebase#initializeCore on channel plugins.flutter.io/firebase_core)"
points towards your Dart code being updated, but your native code hasn't
updated.
Can you try running flutter clean and rebuilding?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3311 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACFWMVS2WDEP5PY6BELKITSCIY4HANCNFSM4QJJEAGQ>
.
--
Mobil: 0708-52 62 90
Teknologgatan 3, 113 60 Stockholm
http://www.oakstair.se
|
I saw some comment about using localhost but have tried 0.0.0.0 or my ip with same result. |
The emulator vs the error message have no relevance - try wiping all the caches, uninstalling the app etc, something is being cached. |
Ok I get this in my development environment running unit tests.
flutter clean does not work
What do you mean by wiping all caches ?
How do I do that?
Den mån 24 aug. 2020 kl 14:40 skrev Elliot Hesp <notifications@github.com>:
… The emulator vs the error message have no relevance - try wiping all the
caches, uninstalling the app etc, something is being cached.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3311 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACFWMXV3SY6M4PDW42PR6DSCJNSRANCNFSM4QJJEAGQ>
.
--
Mobil: 0708-52 62 90
Teknologgatan 3, 113 60 Stockholm
http://www.oakstair.se
|
Ok I get it now that this has nothing to do with pointing firebase to the emulator. I get the same error also when removing the line that configs towards the emulator. It must be something that differs when running my tests and when running my flutter app that causes this. |
My full test class attempt looks like this.
|
I have the same issue. It works fine when I initialize the app in my actual app, but the same MissingPluginException gets thrown when I attempt the same thing in one of my simple tests. |
Hi @oakstair |
Hey @oakstair. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
I will try to get some time today to do a mini project that reproduces this. @eriklange You don’t have a mini project? |
Here is a minproject thar reproduces the bug https://bitbucket.org/oakstair/firestore_missing_plugin_bug/src/master/ |
logs
flutter doctor -v
|
@oakstair I had a few 3rd party packages in my project. Thank you for making the miniproject! |
No problem! When I studied (long time age) I didn't even have any time for studying :-) |
That's understandable! App development is a hobby of mine, so I enjoy every moment of it, especially with Flutter :) |
So... Has anyone managed to run unit tests with FlutterFire ever? I'm getting the same issue and I don't even know if it is meant to work during unit testing or if I should give up the idea of testing... |
I am also facing this issue. Everything runs fine except in testing. |
So I faced a similar issue in testing. I was attempting to create Document References during testing and calling In my case I solved this by pulling the following file into my test directory which hooks into mock call handlers to be used throughout the test: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/cloud_firestore/cloud_firestore/test/mock.dart For reference to contents of file:
Then in each test I would do the following:
|
I think the flutter test is running on neither iOS nor Android, so what if we're talking about running it in a macos environment? flutter testのときはiOSでもAndroidでもない環境で動いていると思います。macosの環境で動かすということにしたらどうでしょうか? |
thank you for sharing, this fixed the error for me |
Not works for me
My test file import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'cloud_firestore_mock.dart';
void main() async {
setupCloudFirestoreMocks();
setUpAll(() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseFirestore.instance.settings = Settings(
sslEnabled: false,
host: '192.168.100.9:8080',
);
});
test('Connect to emulator', () async {
FirebaseFirestore firestore = FirebaseFirestore.instance;
var doc = await firestore.doc('users/user-a').get();
print(doc.data());
});
}
Command to run
Firebase packages
Thanks |
The mocking method does not work for me either, because we have to also mock |
I challenge you to rethink what you are exactly testing and why you need to perform an actual query in your unit test. This library has its own unit tests that test for that. Instead I would consider creating mock objects that resemble the data schema that you would retrieve from firestore. |
There are sometimes need to create an integration test (that does not involve bringing up a simulator) that tests the queries. For web apps, for example, I can bring up the firebase emulator and run integration tests for the queries against it. To reiterate, I don't want to test that the library works, I want to test that:
|
Hey guys, we have a page on the Flutterfire website dedicated to setting up your integration tests here. Alternatively, you can just look at the source code for Flutterfire if you wish to see how we run integration tests using the Firebase emulator suite. |
@russellwheatley Come on bro, how can you close the issue, when the problem still holds??? Whenever I call import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:firebase_core/firebase_core.dart';
void main() {
setUpAll(() async {
TestWidgetsFlutterBinding.ensureInitialized();
// Expose path_provider that interlinked with Android/iOS SDK
const MethodChannel channel =
MethodChannel('plugins.flutter.io/path_provider');
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return ".";
});
await Firebase.initializeApp();
});
test('Blah blah', () {});
}
|
Hey @qiansen1386, I'm saying that using Firebase Emulators for your integration tests will work. But the example you're using is not an integration test, it is a unit test. A unit test does not involve any native API calls (to android or iOS for example). You have to mock the calls to the native platform (i.e |
@russellwheatley Thanks, I think now I understand it better. I am reimplementing my service tests under integration_test/ TBH, the unit test approach is still more preferred. The integration tests can be very slow(building + firing Android/iOS emulators), besides we just want to unit test a service, otherwise we won't use emulators. If I mock the method calls( Is there any hope in the future we can bypass this Android/iOS restriction? |
@qiansen1386, I don't think what you want will work. The vast majority of Flutterfire's API requires interaction with the native platform. If you're not going to run an android/ios emulator, then your only other option is to mock the API calls. |
@russellwheatley Make sense, thank you a lot. I guess I have to use emulators then. |
Failing to write simple unit test using firebase emulators
Yesterday I upgrade to latest and greatest firebase/firestore plugins and decided to try out the firebase emulators to add some testing of my data access objects.
I fail to get the test up and running agains the emulators due to the error below
I saw some other issues that has been closed regarding the same error but with no solution that suited me.
I guess this is a simple mistake form my side in the code when connecting to the emulators.
MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
My test code
Firebase versions
Firebase emulators startup
Flutter doctor
Run
flutter doctor
and paste the output below:The text was updated successfully, but these errors were encountered: