菜鸟教程小白 发表于 2022-12-11 16:52:50

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


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

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

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

<pre><code>XCUIApplication *app = [init];
    [self addUIInterruptionMonitorWithDescription:@&#34;Notification Handler&#34; handler:^BOOL(XCUIElement * _Nonnull interruptingElement) {

    if ( exists])
    {
       tap];
      ;
      return true;
    }
    return false;
}];
</code></pre>

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

<p>有什么想法吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>原来系统警报是导致问题的原因——无论出于何种原因,我的 UIInterruptionMoniter 都没有在机器人上正常运行。在测试期间禁用通知权限警报解决了我的问题。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - XCode UITests 无法运行,出现意外退出错误(仅限机器人),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38151464/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38151464/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - XCode UITests 无法运行,出现意外退出错误(仅限机器人)