Search code examples
iosxcode-ui-testing

Possible to prevent XCode from envoking debugger after calling `XCUIApplication().terminate()`


I'm using UITest for testing an objective C app, using swift for the tests.

XCode 7.3, sim 9.3

Every test case invokes XCUIApplication.launch(), which kills any running application by sending SIGKILL.

Xcode treats this like a crash - invoking the debugger on main.m. To proceed with the test suite I just click the continue button in the debugger.

After hitting continue, my log says:

Message from debugger: Terminated due to signal 9

This situation is frustrating because it happens after 1/4 of my test cases. Causing me to lose focus on the document I'm editing and causing my test suite to hang until I hit continue.

Is there a way around this?


Solution

  • 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