您如何为 Firestore on Unity 编写集成测试?
How do you write integration tests for Firestore on Unity?
我有一个由 Firebase/Firestore 数据库支持的 Unity3D 应用程序。
Firebase 提供了 Local Emulator Suite for testing, but it is not supported on Unity.
似乎测试使用 Firestore 的逻辑的唯一方法是:
- 使用真实的、仅供测试的数据库并在每次设置时清除它
- 模拟 Firestore 的所有用法
(2) 似乎容易出错,就像我在重新发明轮子一样。 (1) 看起来既危险又缓慢。我还缺少另一个广泛支持的选项吗?
现在支持模拟器套件。参见 https://github.com/firebase/quickstart-unity/issues/719#issuecomment-938759588
要使用模拟器,运行
FirebaseFirestore firestore = FirebaseFirestore.DefaultInstance;
firestore.Settings.Host = "localhost:8080";
firestore.Settings.SslEnabled = false;
确保在使用的每个程序集中使用此代码。许多教程在单独的程序集中将测试 运行 作为其余代码。如果您的体系结构相似,则每个程序集中都需要上述代码。具体来说,请务必在访问 FirebaseFirestore.DefaultInstance
时在测试程序集中调用此代码,并在游戏代码中调用此代码,因为 FirebaseFirestore.DefaultInstance
每个进程存在一次(即每个程序集一次)。
我有一个由 Firebase/Firestore 数据库支持的 Unity3D 应用程序。
Firebase 提供了 Local Emulator Suite for testing, but it is not supported on Unity.
似乎测试使用 Firestore 的逻辑的唯一方法是:
- 使用真实的、仅供测试的数据库并在每次设置时清除它
- 模拟 Firestore 的所有用法
(2) 似乎容易出错,就像我在重新发明轮子一样。 (1) 看起来既危险又缓慢。我还缺少另一个广泛支持的选项吗?
现在支持模拟器套件。参见 https://github.com/firebase/quickstart-unity/issues/719#issuecomment-938759588
要使用模拟器,运行
FirebaseFirestore firestore = FirebaseFirestore.DefaultInstance;
firestore.Settings.Host = "localhost:8080";
firestore.Settings.SslEnabled = false;
确保在使用的每个程序集中使用此代码。许多教程在单独的程序集中将测试 运行 作为其余代码。如果您的体系结构相似,则每个程序集中都需要上述代码。具体来说,请务必在访问 FirebaseFirestore.DefaultInstance
时在测试程序集中调用此代码,并在游戏代码中调用此代码,因为 FirebaseFirestore.DefaultInstance
每个进程存在一次(即每个程序集一次)。