OGeek|极客世界-中国程序员成长平台

标题: ios - XCode UITests 无法运行,出现意外退出错误(仅限机器人) [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 16:52
标题: ios - XCode UITests 无法运行,出现意外退出错误(仅限机器人)

即使只是运行默认的 testExample 类(没有代码),我的 XCode UI 测试也无法使用机器人运行。相反,我收到一个错误:

Testing failed: Test target UIBotTest encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted) ** TEST FAILED **

在机器人之外,我的测试正在运行并通过,没有出现这样的失败。 我尝试实现的一个解决方案是利用系统警报处理程序在应用程序首次启动时处理通知权限警报,如下所示:

XCUIApplication *app = [[XCUIApplication alloc]init];
    [self addUIInterruptionMonitorWithDescription"Notification Handler" handler:^BOOL(XCUIElement * _Nonnull interruptingElement) {

    if ([interruptingElement.buttons[@"OK"] exists])
    {
        [interruptingElement.buttons[@"OK"] tap];
        [app tap];
        return true;
    }
    return false;
}];

我尝试在我的 setUp 和 testExample 函数中实现这一点,它再次在模拟器和物理设备上运行良好,但在机器人上失败并出现同样的错误。

有什么想法吗?



Best Answer-推荐答案


原来系统警报是导致问题的原因——无论出于何种原因,我的 UIInterruptionMoniter 都没有在机器人上正常运行。在测试期间禁用通知权限警报解决了我的问题。

关于ios - XCode UITests 无法运行,出现意外退出错误(仅限机器人),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38151464/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) Powered by Discuz! X3.4