ios - XCode UITests 无法运行并出现意外退出错误(仅限机器人)

标签 ios xcode xcode-ui-testing

即使只是运行默认的 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 函数中实现它,它再次在模拟器和物理设备上运行良好,但在机器人上失败并出现相同的错误。

有什么想法吗?

最佳答案

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

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

相关文章:

ios - 在 Swift 中使用 commitEditingStyle 动态删除 UITable 部分

iphone - po 对象导致错误 : cannot find interface declaration for '$__lldb_objc_class'

xcode - 检查专注于 XCUITest 的 UITextField

iOS,如何在同一 View 上播放多个视频?

ios - 是否可以仅使用常量属性在两个结构之间实现双向关系?

ios - ios 中的 UItableviewcell 重用问题

ios - 如何在我的 UINavigationBar 后面获得模糊效果

ios - XCTest:如何正确设置 UITextView 的可访问性特征?

ios - 与照片相关的警报不会调用 addUIInterruptionMonitor 的处理程序

objective-c - Objective c - 滚动表格 View 时发生奇怪的泄漏