调用`XCUIApplication().terminate()`后,可以防止XCode调用调试器

mki*_*irk 5 ios xcode-ui-testing

我正在使用UITest测试一个客观的C app,使用swift进行测试.

XCode 7.3,sim 9.3

每个测试用例都调用XCUIApplication.launch(),它通过发送SIGKILL来杀死任何正在运行的应用程序.

Xcode将此视为崩溃 - 调用调试器main.m.要继续测试套件,我只需单击调试器中的继续按钮即可.

点击继续后,我的日志说:

Message from debugger: Terminated due to signal 9
Run Code Online (Sandbox Code Playgroud)

这种情况令人沮丧,因为它发生在1/4的测试用例之后.导致我失去对正在编辑的文档的关注,导致我的测试套件挂起,直到我继续.

有没有解决的办法?

kdu*_*ubb 4

We experienced the same issue. After some debugging we found out this was caused by having Background Modes enabled for your app.

Our solution was to make a new target for development and testing that has all Background Modes disabled.

FYI, in the Capabilities section of your project settings it's labeled as Background Modes turning this Off is key. Alternatively, you could remove the Require background modes (aka UIBackgroundModes) key from your Info.plist