openbakery / gradle-xcodePlugin

gradle plugin for building Xcode Projects for iOS, watchOS, macOS or tvOS
Apache License 2.0
457 stars 129 forks source link

XCTest UI Tests can't find the simulator #434

Closed jimadamsss closed 4 years ago

jimadamsss commented 4 years ago

I noticed while building that the simulator was killed but I never saw it come back. All my UI tests failed with errors similar to the following: FAILED -[SASCollectorUITestAppUITests.SASCollectorUITestAppUITests testInAppDismiss] - (5.021 seconds) t = 0.00s Start Test at 2020-06-23 17:02:19.811 t = 0.05s Set Up t = 0.05s Open com.sas.ci.SASCollectorUITestApp t = 0.10s Launch com.sas.ci.SASCollectorUITestApp t = 0.30s Setting up automation session t = 0.31s Wait for com.sas.ci.SASCollectorUITestApp to idle t = 1.63s Tap "Show Inapp" StaticText t = 1.63s Wait for com.sas.ci.SASCollectorUITestApp to idle t = 1.67s Find the "Show Inapp" StaticText t = 2.72s Find the "Show Inapp" StaticText (retry 1) t = 3.75s Find the "Show Inapp" StaticText (retry 2) t = 3.78s Collecting extra data to assist test failure triage t = 3.78s Requesting snapshot of accessibility hierarchy for app with pid 70030 t = 3.80s Requesting snapshot of accessibility hierarchy for app with pid 70030 t = 3.82s Find: Descendants matching type StaticText t = 3.82s Find: Elements matching predicate '"Show Inapp" IN identifiers' t = 3.85s Assertion Failure: SASCollectorUITestAppUITests.swift:57: Failed to get matching snapshot: No matches found for Descendants matching type StaticText from input {( Application, pid: 70030, label: 'SASCollectorUITestApp'

When run in Jenkins I am seeing that the UIApplication isn't able to launch the test app.

Is there something I have to do to enable the simulator again?

renep commented 4 years ago

The gradle-xcodePlugin is nothing else but a wrapper for the apple commandline tools like xcodebuild. When running tests the plugin composes the xcodebuild command the executes the tests. You can run gradle with the option -i or --debug then you see xcodebuild command that is used. You can try to run the xcodebuild directly and see if you see the same behaviour (what should be). Normally when the simulator crashes, also a crashlog should be created. Maybe you find a hint there.

jimadamsss commented 4 years ago

Turns out I was misreading the test results. It looked like it couldn't find the running application but it instead couldn't find the visual element. I had been running in Xcode with a different simulator from my Gradle builds.