9

I'm working on building a UI Test suite for my iOS app. I need to test my app's functionality on several different devices, but right now I have to select the simulator I want, run the tests, and then repeat.

Now that Xcode supports multiple simulators running in parallel, is there a way to run the UI tests across several different device simulators at the same time?

Bill
  • 44,502
  • 24
  • 122
  • 213

2 Answers2

5

Run the following command in the same directory as your project to run your tests in parallel from the command line:

xcodebuild test -scheme "YourSchemeName" -destination 'platform=iOS Simulator,OS=11.2,name=iPhone 8' -destination 'platform=iOS Simulator,OS=11.2,name=iPhone 6s'  -configuration "Debug" ENABLE_TESTABILITY=YES SWIFT_VERSION=4.0 ONLY_ACTIVE_ARCH=YES

You can add -destination 'platform=iOS Simulator,OS=11.2,name=iPhone 8' for a different destination for as many different destinations as you would like.

For a list of simulator names and OSs that are available, run the command:

instruments -s devices

Bear in mind that if you are running tests in the simulator, you will not see the simulators on your screen when running tests through the command line.

Oletha
  • 7,324
  • 1
  • 26
  • 46
  • 1
    For Xcode 13 and later, use `xctrace list devices` instead. (`instruments` has been removed.) – freya Apr 17 '23 at 21:30
2

In Xcode:

  1. Select your target scheme in Xcode, and "Edit Scheme..."
  2. Find the settings for "Test", and press on the "Info" tab
  3. You'll see a list of your Unit and UI tests, press on the associated "Options..." button
  4. Select "Execute in parallel on Simulator"
  5. Optionally select "Randomize execution order"

Enable Parallel Testing


Commandline:

Look at this answer here

Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278