Sauce Labs offers the ability to run automated tests on our real device cloud using XCUITest, the native app testing framework for running user interface tests on iOS devices.
Developed by Apple, XCUITest is built on the XCTest framework and included as part of the iOS Xcode development tools. Tests are written in ObjectiveC/Swift, and are built as a
.ipa file, which is loaded and executed on the device along with the application you're testing.
To begin, you'll need to download and configure our test runner, Sauce Runner for Real Devices, which is parameterized for use in your CI/CD environments. This will enable you to run tests against one or more devices in parallel, with test reporting that includes video, screenshots, and logs of your tests. As an alternative, you can also run Espresso and UI Automator tests from the Sauce Labs web interface.
What You'll Need
Requirements for using XCUITest with Sauce Runner for Real Devices:
- Set up your mobile app testing project
- Have the .ipa files for both your app and tests
- Have Java 8 or later installed on your local machine
Download Sauce Runner for Real Devices
Click this link to download Sauce Runner for Real Devices, version 1.10 (.jar file).
Configuring Sauce Runner for Real Devices for XCUITest
Command Line Arguments
See Command Reference for Sauce Runner for Real Devices for a list of options you can use to configure Sauce Runner for Real Devices to run tests with XCUITest.
Building Your iOS App
When you are ready to build the .ipa file for your app to use with Sauce Runner for Real Devices, you need to make sure that the iOS version you set for the iOS Deployment Target for both the application and your test runner match. If these don’t match, your tests will run locally, but fail when you run them against the Sauce Labs real devices. You can set this for both Projects and Targets of your application in the Xcode Build Settings.
Select the Project you want to build, and under Build Settings, set the iOS Deployment Target to the iOS operating system version you want to use in your test. All target outputs of this project, including the application and your test runner, will be set to the same operating system version.
Select the Target for your Project, and under Build Settings, set the iOS Deployment Target to the iOS operating system version you want to use in your test. This will also overwrite the Build Settings at the Project level to that operating system version, so if you use this method, be aware that your Targets can become out of synch with each other and the Project settings, and your tests will break. If you change the iOS version for one target output, you may want to build the Project again to make sure all your targets are in synch.
XCUITest Max Execution Time
The execution time for a single XCUITest test is one hour. Our recommended best practice is to keep all tests "Small, Atomic, and Autonomous," with maximum execution times in minutes or seconds, so you can get the most efficiency for your builds.