I have been trying to find a solution to run UI Tests for iOS projects without launching the iOS Simulator. My intention is to run xcodebuild
command from Terminal for CI pipeline but without launching the iOS Simulator.
I am using below command to run UI test suite for my iOS project, this works fine but launches the iOS Simulator
xcodebuild test -project iOSTesting.xcodeproj -scheme 'iOSTestingUITests' -destination 'platform=iOS Simulator,name=iPhone 15 Pro' -destination 'platform=iOS Simulator,name=iPhone 15'
I was able to find a solution on GitHub where the UI Tests run without launching the iOS Simulator, but I am not able to find out how it is working, here is the link to the source code. https://github.com/Shashikant86/Xcode9-XCTest
Any thoughts?
I was able to reproduce the behavior of the project you pointed to by making a new project and running xcodebuild
on it. Follow these steps to try it:
Make a new storyboard-based iOS project called MyCoolApp, including tests. Save it on the Desktop.
Make sure that you have created a Simulator for iPhone 15, OS 17.2. I don't know whether this step is necessary but let's not take any chances.
Launch the Terminal and cd Desktop/MyCoolApp
.
Still in the Terminal, give this command, which is essentially the command that you provided:
xcodebuild -project MyCoolApp.xcodeproj -scheme "MyCoolApp" -destination 'platform=iOS Simulator,name=iPhone 15,OS=17.2' build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
The tests run but at no time does the Simulator app appear on the screen.