Xcode UI Tests are failing because of XCApplicationStateRunningActive on physical device
Asked Answered
D

3

15

In my app I'm adding some UI tests. With one test method everything works perfectly, but when I added second method, the test is failing because of the following error: enter image description here

I feel like [[[XCUIApplication alloc] init] launch]; doesn't terminate the app as it suppose to.

EDIT 1:

I also noticed, if I press home button on my physical device after test finishes, I can see 2 instances of the app still running on the background. And if I try to start the tests again I get the message in Xcode that it can not start running the app because the app null is still running. This is frustrating :(

Does anyone have a clue or had a similar issue?

Any kind of help is highly appreciated.

Discretion answered 17/12, 2015 at 1:42 Comment(8)
Same issue here... keen to know if you find an answer. More info - even with many tests, it's always the second one that produces this error (even after changing the order of tests). Have you tried creating tests in a blank iOS app?Harmony
No, didn't try with the empty app...but I need these tests working with my current app :)Discretion
Can I suggest everyone with the same issue submits a bug report to Apple? If it's really a problem for anyone, using a 'technical support incident' has escalated the problem into the hands of an engineer on the relevant team in the past for me, could be worth a shot.Harmony
Not an answer, but perhaps helpful debugging info: I have this same problem when running my UI tests on Travis. Initially the first test passed, and all subsequent tests failed. I suspect the Travis instances are headless, causing issues for UI tests. I noticed that my app had some constraint issues with very small windows, and, by fixing issues with small displays, I was able to pass more, though not all, of my UI tests on Travis. Are headless OSX instances possible? Do they have a very low resolution or other limitations?Bludge
My radar on this has been closed as a dupe of 23920068. Also see this discussion on the Apple forums.Poser
forced quit the simulator and ran tests again fixed the issue for meWiedmann
I feel like todays xcode update Version 7.2.1 (7C1002) fixed this issue, can anyone who had this issue too confirm?Discretion
I have the same issue, but while running tests on CI server. Also it appears randomly on test start, but never, when I run test from XCode. XCode 7.3 beta 5 didn't helpDrida
M
1

I have submitted a bug report and have been asked to test on Xcode 7.3 beta 3. It is fixed! You can check my radar 24524204‌ that is now closed as resolved.

Mafaldamafeking answered 10/2, 2016 at 13:58 Comment(1)
yes, I know, If you read my comment from Feb 3 at 20:36 you would see that :)Discretion
H
2

This sounds like the app isn't being torn down correctly after the first test is completed. Try explicitly killing the app in your tear down method.

- (void)tearDown {
    [[[XCUIApplication alloc] init] terminate];
    [super tearDown];
}
Hardwood answered 17/12, 2015 at 11:2 Comment(4)
I've the same problem and have tried this and dose not solve the problem for me. I am running on device and using xcode 7.2.Whitehurst
Same thing is happening for me too as well ever since I updated to 7.2Xerox
@JamesGoe tried that, this way it shows both tests failingDiscretion
Same thing here. Even killing the app does not sets the proper app stated before the next test begins.Pierrette
H
1

Updating to 7.3 beta resolved this issue for me. It definitely seems to be related to the teardown functionality.

Hyperdulia answered 9/2, 2016 at 20:6 Comment(0)
M
1

I have submitted a bug report and have been asked to test on Xcode 7.3 beta 3. It is fixed! You can check my radar 24524204‌ that is now closed as resolved.

Mafaldamafeking answered 10/2, 2016 at 13:58 Comment(1)
yes, I know, If you read my comment from Feb 3 at 20:36 you would see that :)Discretion

© 2022 - 2024 — McMap. All rights reserved.