XCTest应用程序testing和权限警报
我正在编写XCTest应用程序testing,通过在UIApplication
rootViewController
上调用presentViewController
来testing一些UIViewControllers
。
这工作正常,除权限对话框。 一些UIViewControllers
为相机或麦克风访问等东西创build系统popup权限对话框。 我不知道如何解雇他们。
如果这是一个UItesting,我可以使用addUIInterruptionMonitorWithDescription
并tap
警报。
但是,我不知道如何使这项工作。 应用程序可以testing访问UItestingfunction吗?
在xcode uitesting中,要访问系统popup权限对话框,请使用以下代码:
self.addUIInterruptionMonitorWithDescription("your alert text", handler: { (alert) -> Bool in yourAlertElement.tap() return true })
希望这会有所帮助,如果你有任何困惑,让我知道。