我想创建一个简单的UI测试,通过一个应用程序的账户创建,然后与firestore检查,以验证用户的数据是否正确。到目前为止,我已经完成了UI驱动。测试通过账户创建来驱动应用程序,我可以手动验证数据是否正确。我现在的障碍是能够从测试文件中配置Firebase、Firestore和Firebase Auth。我还没有成功地按照应用本身的方式进行配置 (FirebaseApp.configure()
指向plist配置文件),错误在于它没有看到一个有效的GoogleService-Info.plist文件。另一个相关的挑战是从测试文件中访问auth,特别是获取当前登录的uid,这样我就可以在Firestone中定位用户的数据。有什么好办法吗?有什么办法吗?
另外,为了方便起见,我想创建这些集成测试,使它们能够通过fastlane+github组合作为CICD的一部分运行,尽管这不一定是这个问题的一部分。
要将Firebase添加到你的iOS项目中,你必须按照? 文件:
我假设你已经按照步骤1和2创建了一个Firebase项目,并在Firebase上注册了你的应用程序。
1- 点击 Download GoogleService-Info.plist 来获取你的 Firebase iOS 配置文件(GoogleService-Info.plist)。
2- 将配置文件移动到Xcode项目的根目录下。如果出现提示,选择将配置文件添加到所有目标。
1- 我们建议使用CocoaPods来安装Firebase库。如果你还没有,请创建一个Podfile。
cd your-project-directory
pod init
2- 在你的Podfile中,添加你想在应用中使用的Firebase pods。
# Add the pods for the Firebase products you want to use in your app
# For example, to use Firebase Authentication, Cloud Firestore, and Realtime
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Database'
3- 安装pods,然后打开你的.xcworkspace文件,在Xcode中查看项目。
pod install
open your-project.xcworkspace
1- 在你的UIApplicationDelegate中导入Firebase模块。
import Firebase
2- 配置一个FirebaseApp共享实例,通常在你的应用程序的 application:didFinishLaunchingWithOptions:
方法。
// Use Firebase library to configure APIs
FirebaseApp.configure()