[英]Unit Testing firebase_auth and firestore
I am trying to setup flutter scripts for testing my classes that interface with my firestore database.我正在尝试设置 flutter 脚本来测试与我的 firestore 数据库接口的类。
My current struggles are:我目前的挣扎是:
Is there any way to write unit/integration tests for firebase_auth or firestore without mocking?有没有办法在不模拟的情况下为 firebase_auth 或 firestore 编写单元/集成测试? I'm even happy using a local emulator/export of my database if that's a thing that's even possible.
如果这是可能的,我什至很高兴使用我的数据库的本地模拟器/导出。
Here are a number of the articles I have reviewed that are not what I am looking for:以下是我查看过的一些不是我要查找的文章:
Alright, I think I have found what I am looking for.好吧,我想我已经找到了我要找的东西。 The firebase team does a really good job showing how to test security rules in Unit testing security rules with the Firebase Emulator Suite .
firebase 团队在使用 Firebase Emulator Suite 单元测试安全规则中展示了如何测试安全规则的工作非常出色。
What I did was I ran firebase init in my actual flutter project directory and this article Use the Firestore Emulator with Flutter shows how to access the emulator directly in flutter, however the command to initialize is now我所做的是在我的实际 flutter 项目目录中运行了 firebase init,这篇文章使用 Flutter 使用 Firestore 模拟器展示了如何直接在 flutter 中访问模拟器, 但是现在要初始化的命令是
FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080); FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080);
Combining these, I think it should be possible to test whether or not one is writing the correct data within the correct format into the database along with ensuring the the data that's returned matches what's intended regardless of whether or not you are using Freezed, Json Serializable, dart:convert, etc...结合这些,我认为应该可以测试是否以正确的格式将正确的数据写入数据库,同时确保返回的数据与预期的匹配,无论您是否使用 Freezed、Json Serializable ,飞镖:转换等...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.