【发布时间】:2017-12-26 22:55:57
【问题描述】:
以下测试在 iOS 11 上运行良好。它会关闭询问权限以使用位置服务的警报,然后放大地图。在 iOS 10 或 9 上,它什么都不做,测试仍然成功
func testExample() {
let app = XCUIApplication()
var handled = false
var appeared = false
let token = addUIInterruptionMonitor(withDescription: "Location") { (alert) -> Bool in
appeared = true
let allow = alert.buttons["Allow"]
if allow.exists {
allow.tap()
handled = true
return true
}
return false
}
// Interruption won't happen without some kind of action.
app.tap()
removeUIInterruptionMonitor(token)
XCTAssertTrue(appeared && handled)
}
有人知道原因和/或解决方法吗?
这是一个可以重现该问题的项目:https://github.com/TitouanVanBelle/Map
更新
Xcode 9.3 Beta 的变更日志显示以下内容
XCTest UI 中断监视器现在可以在运行 iOS 10 的设备和模拟器上正常工作。(33278282)
【问题讨论】:
标签: ios swift xctest xcode-ui-testing