XCUITest failures... so many failures!

Struggling every single day to get consistent testing results, and over the past few days I've run into a whole series of brand new exciting issues!

Why did these new issues show up on a branch of code that never changes? Who knows! They seemed to work OK when I switched to Xcode 9.2... until they didn't, for mysterious reasons. I don't get it.


I have two tests, triggered hourly by an XCBot, running on 1 10.3 and 3 11.2 simulators. I've tried running tests in parallel and not.

I can run these tests 20 times on my XCBot and get 20 different results.


Run each set of tests manually in Xcode on the same codebase (command-U in Xcode) and every test passes perfectly on every simulator.

The list of weirdo problems:

  • Test Assertion: Failed to terminate com.****.****:3850 after 60.0s; state is still `Running Foreground` (this is the big one for me; one I've never seen before)
  • Test Assertion Launch session expired
  • Explicit assertions made by me are reported with the cryptic "Test Assertion Crash: UITests-Runner: implicit closure #1 in UITests" rather than my assertion statement (although sometimes I get both and sometimes I only get my own message)
  • An assertion that the count of a particular on-screen element should be greater than 0 fails even though the automated screenshot clearly shows the elements being counted and those same tests run perfectly outside of the XCBot environment.

I'm at a total loss here.

Replies

The "Failed to terminate" problem seems to occur when a simulator runs a UITest, finishes that test, then tries to launch the app to run the second test. In the second test, the setup() routine is run which tells XCUIApplication().launch. But to launch, it must first terminate the running instance. That is where it fails.

The "implicit closure" failure I've identified as being unique to iPhone X Simulator running iOS 11.2.

I've expanded on the problem in a separate post: https://forums.developer.apple.com/thread/94164

OP, did you manage to fix this issue? I am facing the same "Failed to terminate...still running in foreground" message and I'm completely lost on how to fix it.

I have the same problem, "Failed to terminate...". I have an old Mac Mini 2010 and an old iPhone 5s. I have there problems even when I run them inside Xcode via Cmd+U.

I'm facing the same "Failed to terminate..." problem. I have a iMac Late 2015 and I'm running my UI Tests in the iPad Air 2 (11.2) simulator.


I run my tests over night and it appears that out of my 126 tests, it's only the last 20 tests are failing with this "Failed to terminate..." problem.