【发布时间】:2017-04-19 19:54:30
【问题描述】:
我正在为我的应用编写 XCUITest。
我声明警报是为了使用waitForExpectationsWithTimeout 使我的测试异步......但是它在第5 行alert 的声明中抛出了错误Variable used within its own initial value。
let timeout = NSTimeInterval()
let app = XCUIApplication()
let exists = NSPredicate(format: "exists == 1")
let alert = alert.buttons["OK"]
testCase.addUIInterruptionMonitorWithDescription("Enable Notifications") { (alert) -> Bool in
alert.buttons["OK"].tap()
return true
}
self.buttons["Enable notifications"].tap()
testCase.expectationForPredicate(exists, evaluatedWithObject: alert, handler: nil)
testCase.waitForExpectationsWithTimeout(timeout, handler: nil)
app.tap()
谁能告诉我为什么会抛出这个错误以及我能做些什么来解决这个问题。提前致谢。
【问题讨论】:
标签: ios swift xcode xcode-ui-testing