Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run several iOS UI Tests in Parallel?

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?

like image 305
Bill Avatar asked Dec 11 '17 14:12

Bill


People also ask

Does Xcode run tests in parallel?

Xcode has the power to randomise unit tests or even run them in parallel, but sometimes in using those features we can make the tests less stable (or show you that they are unstable but just did not notice).

How do I test my IOS UI?

When you're ready to test, go to a test class and place the cursor inside the test method to record the interaction. From the debug bar, click the Record UI Test button. Xcode will launch the app and run it. You can interact with the element on-screen and perform a sequence of interactions for any UI test.

What is difference between unit tests and UI test in Xcode?

The really short version is that unit tests have access to the code in your app (or whatever kind of module you are building) and UI tests do not have access to the code. A unit test only tests one single class per test.

How do I add a UI test to Xcode project?

The easiest way to add a unit test target to your project is to select the Include Tests checkbox when you create the project. Selecting the checkbox creates targets for unit tests and UI tests. To add a unit test target to an existing Xcode project, choose File > New > Target.


1 Answers

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.

like image 81
Oletha Avatar answered Sep 20 '22 15:09

Oletha