Skip to content
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

Idea: a way to run cloud_firestore_mocks_test.dart with real Firestore #17

Closed
suztomo opened this issue Feb 24, 2020 · 6 comments · Fixed by #39
Closed

Idea: a way to run cloud_firestore_mocks_test.dart with real Firestore #17

suztomo opened this issue Feb 24, 2020 · 6 comments · Fixed by #39

Comments

@suztomo
Copy link
Collaborator

suztomo commented Feb 24, 2020

I wish there is a way to run the test with real Firestore instance. With such setup, contributors of this repository feel confident that cloud_firestore_mocks follows the behavior of the real implementation.

@suztomo
Copy link
Collaborator Author

suztomo commented Feb 25, 2020

Authentication is a challenge.

Firebase Emulator does not require authentication. https://firebase.google.com/docs/rules/emulator-setup.

Using the emulator to develop cloud_firestore_mocks. The cloud_firestore_mocks users can benefit from easy Firestore unit tests (without setting up the emulator).

@suztomo
Copy link
Collaborator Author

suztomo commented Feb 25, 2020

Integration Test with contributor's dummy Firebase project (no security)

(Didn't work)

Test Structure

The driver app cannot touch firestore package either, because it depends on "dart:ui".

../../development/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.13.3/lib/cloud_firestore.dart:8:8: Error: Not found: 'dart:ui'
import 'dart:ui' show hashList;
       ^

Instruction

  • Create a dummy Firebase project
  • Set development rules (no security)
  • Place GoogleService-Info.plist to Runners/Runners via Xcode.
  • Run flutter drive --target=test_driver/app.dart

My memo: https://gist.github.com/suztomo/eb37e00a0d0d8f364245e775d7af2861

@suztomo
Copy link
Collaborator Author

suztomo commented Feb 25, 2020

Integration test for test app that calls CloudFirestoreMockTests with a dummy (real) firebase project

Can test-driver/app.dart call CloudFirestoreMockTests from runApp?

@atn832
Copy link
Owner

atn832 commented Mar 1, 2020

What about these integration tests? They seem to be doing what you are trying to do. Why do they not fail as well?
https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_firestore/cloud_firestore/example/test_driver

Did you get a chance to try with the Emulator that you mentioned? It would make it cleaner since we wouldn't need to create an actual account and a test database.

@suztomo
Copy link
Collaborator Author

suztomo commented Mar 1, 2020

Thank for the reference for the integration test. It should work as long ad test code is in app side, not driver code. I will give it a try.

Emulator with widget test didn’t work for me.
I followed https://firebase.google.com/docs/emulator-suite/connect_and_prototype
Firestore’s “setting” method (to specify localhost) never returned. Real Firestore client code needs a real device. Therefore it does not run in a widget test. Running it as a integration test may work.

@suztomo
Copy link
Collaborator Author

suztomo commented Mar 10, 2020

Found example directory.

suztomo@Tomohiros-MBP.verizon.net ~/Documents/cloud_firestore_mocks/example
~/Documents/cloud_firestore_mocks/example $ flutter drive --target=test_driver/cloud_firestore.dart

Using device iPhone 11 Pro Max.
Starting application: test_driver/cloud_firestore.dart
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before
submitting to the App Store.
 
Running pod install...                    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants