Xcode UI Tests are failing because of XCApplicationStateRunningActive on physical device

≯℡__Kan透↙ 提交于 2020-01-12 03:20:07

问题


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:

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.


回答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.




回答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];
}



回答3:


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



来源:https://stackoverflow.com/questions/34325297/xcode-ui-tests-are-failing-because-of-xcapplicationstaterunningactive-on-physica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!