是否可以在 Firebase 上运行 Flutter 集成测试?似乎有关于此的相互矛盾的信息 - 一些消息来源说它可能,但在 the documentation ,iOS 部分似乎仅用于在您自己的设备上进行测试。
Firebase 要求上传 XCT 测试包。如何为 Flutter 项目获取/创建它?
最佳答案
首先在 Xcode 中打开你的 ios 模块,如下面的 ss。
现在你可以自由地用 Swift 编写很酷的 XCode UI 测试了。例如,我在这里为您的应用程序放置一个 Firebase 登录测试,也许您希望使用。
import XCTest
import UIKit
import Firebase
class LoginTestUITests: XCTestCase {
var app: XCUIApplication!
func testLogin() {
continueAfterFailure = false
app = XCUIApplication()
app.launch()
wait(for: 2)
passLogin()
wait(for: 5)
// after your login you can add some methods here according to your app flow
}
}
extension LoginTestUITests {
func passLogin() {
//put your logic here
}
// this is a pretty cool extension waiting according to input for a while coming the data from backend etc.
extension XCTestCase {
func wait(for duration: TimeInterval) {
let waitExpectation = expectation(description: "Waiting")
let when = DispatchTime.now() + duration
DispatchQueue.main.asyncAfter(deadline: when) {
waitExpectation.fulfill()
}
// I use a buffer here to avoid flakiness with Timer on CI
waitForExpectations(timeout: duration + 0.5)
}
}
关于ios - Firebase 上 iOS 的 Flutter 集成测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66042050/