Reputation: 657338
I want to test my Firebase data access layer with direct access to Firebase.
Is flutter drive
the only way to run such tests, or are there other ways like running in emulator using flutter test
?
What are the possible approaches and how can I set them up?
Upvotes: 3
Views: 752
Reputation: 116728
I'm not aware of a way to talk to a real database with flutter test
currently, because there's no Firebase SDK to do the talking to the network. You probably wouldn't want this anyway, because it could make your tests nondeterministic or flaky if the data changes or the Firebase servers aren't accessible.
Some plugins, like shared_preferences
, have an API for providing mock values. You could do something like that for the firebase_database
plugin, either as a pull request to the first-party repo or by calling MethodChannel.setMockMethodCallHandler
and BinaryMessages.handlePlatformMessage
in your test code to simulate what the native side would be doing.
Upvotes: 3