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

2

5

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?

Disciplinary answered 4/4, 2016 at 17:26 Comment(4)
While not a direct solution, you could always turn off breakpoints with ⌃⌘Y or delete/disable the exception breakpoint.Billbug
@JoeMasilotti Which breakpoint are you suggesting I delete? XCode's breakpoint manager (⌘7) shows "No Breakpoints". It seems to be a "built in" behavior. Event after disabling breakpoints system wide as you suggested (⌘Y), I still get dumped into my debugger just as frequently between UITest restarts.Disciplinary
Do you do tearDown() after test case?Angarsk
@Angarsk - You shouldn't have to as launchApp() will kill the app if it's already running. But also - yes, I've tried that, and saw no measurable difference.Disciplinary
H
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

Halbert answered 13/5, 2016 at 1:22 Comment(1)
This also fixes asserts on XCUIApplication().launch() "UI Testing Failure - Failure attempting to launch".Simla
A
0

You can go for debugging and/or testing after termination using xCode. In the menu:

  1. Debug
  2. Attach to Process
  3. Choose from Likely Targets or By Process Identifier (PID)
Armagh answered 11/8, 2017 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.