Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode UI Tests are failing because of XCApplicationStateRunningActive on physical device

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.

like image 803
Eugene Gordin Avatar asked Dec 17 '15 01:12

Eugene Gordin


Video Answer


1 Answers

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];
}
like image 157
Joe Masilotti Avatar answered Oct 20 '22 03:10

Joe Masilotti