How to Get Started with XCUITest Using Real Devices on Cloud

Bitbar, the mobile devops company. Logo, large

The Apple’s XCUITest has quickly become very popular among the iOS app developers, and testers as well. We’re extremely excited about this framework as it has enabled many of our users to adopt a new framework since UI Automation was deprecated. The XCUITest framework is not really new, but its foundation XCTest has been as part of the Xcode for some years already.

Let’s take a look at XCUITest and how to get started with it and run your tests on remote real devices on a cloud service.

Mobile apps and games created for iOS devices can be tested using various different test automation frameworks. Apple has provided its own ‘official’ test automation frameworks, such as XCTest and XCUITest, as an integral part of Xcode. And as being tightly integrated with Xcode, both XCTest and XCUITest support writing test cases with subclasses, methods and assertions.

Naturally, both of these frameworks are available and supported with Bitbar Testing solutions, and this blog provides all details of how to get up and running tests on Bitbar Public Cloud using XCUITest.

Step 1: Configure Your App for Unlimited Parallelism on Real Devices

Concurrent mobile test runs are very important factor for your efficiency and productivity, and how to use test automation to improve these. There is really only one thing you have to check to ensure your app is able to run on any of iOS devices in Bitbar Public Cloud. Open the Scheme Editor and verify that in Run column all test targets are checked (enabled).

Now, check that all classes that you want to include in the test bundle are properly included with the test target membership.

include test class membership

NOTE! If you are using Swift, annotation @testable imports all required modules for the test bundle.

Step 2: The Right Way to Build Your IPA and Test Package

The next step is to build your application IPA and test package the right way. In order to do this properly, you should follow up all these steps to ensure app is possible to be installed, launched and executed in any iOS devices in Bitbar Public Cloud.

If you are not familiar with these frameworks, check out the XCUITest Tutorial for iOS App Testing.

Now, regardless of which framework you are using (XCTest, XCUITest, or something else) the application under test needs to be built and imported to Bitbar Testing cloud. The following steps show how to create an IPA that is executable on iOS devices.

In Xcode: Click Product -> Build for -> Testing.

build ipa for testing using xcode

Finally, when you are building your IPA and test package for Bitbar Public Cloud test run, you should always build your app using a real device as a build target:

using real ios device as build target

The built application must be packaged also to ZIP file. The easiest way to do this is to use Xcode’s preview and right click Show it in Finder above the right .app file.

right click on xcode to zip file up

In Finder, right click the .app file and copy its path. This path does not change from build to build so this step needs to be done only once.

finder view to zip test package

The IPA package needed for XCTest in Bitbar Public Cloud is a zip package and its creation can be automated and made part of a CI integration. Open a terminal and create the IPA as follows:

$ mkdir /tmp/Payload
$ cd /tmp/Payload
$ cp -r /Users/username/Desktop/Build/Products/Debug-iphoneos/ .  # app path can be pasted
$ cd ..
$ zip --symlinks -qr "LocalizationDemo.ipa" Payload
$ ls -lrt LocalizationDemo.ipa
-rw-r--r--  1 username  staff  0 Dec 16 12:42 LocalizationDemo.ipa

NOTE! If you build for iPhone 5 or iPhone 5C (with ARMv7 32-bit processor) devices then an additional step is needed before creating the build. Starting from Xcode7 onwards ARMv7s is no more part of the default $(ARCHS_STANDARD) and so should be added as target build architecture.

Step 3: Log in to Bitbar Cloud and Create XCUITest Project

After you have followed through all above steps, just log in to Bitbar Public Cloud and create XCUITest project from Projects menu.

create xcuitest project in bitbar cloud

Step 4: Upload your Application IPA and Test Package

Start by clicking the green plus button on the top right corner of the view. This will open you a test run creation wizard that helps setting up all parameters right for your test. The test run creation wizard asks both application file (IPA) and test package (.zip).

upload your ipa file to bitbar cloud

This is very handy as if you don’t need to change the app or test package you don’t have to upload it again, but the old one previously uploaded can be used for a test run.

upload test package for bitbar cloud

Step 5: Select Any Number of iOS Devices for Your Test Run

This is where the real benefit of Bitbar Cloud execution comes into play. You can use any number of iOS devices for simultaneous test runs (we’re NOT limiting number of concurrently used iOS devices anyhow!). So, pick the devices you want for a test run on the test run creation wizard step number 3.

unlimited parallelism in bitbar cloud

After this is done, simply click through the wizard and start a test run. The green START button is available in all phases of the test run creation wizard on bottom right.

All Done! Now, let’s take a look at results!

The first thing after test runs are ready is to check how it did on devices you picked for a test run. The first view provides details of test success/failure on each and every device. This view also provides information on how to long the test run took
device run view at bitbar cloud

Bitbar solutions provide all details about the test runs and this includes recorded video of the session (check with your Bitbar rep how to enable this), screenshots, logs, performance statistics and all fine-grained details about device session. All this material will help you to fix and shape the app to work better on real devices, the very same devices that your end-users use.

detailed view of bitbar public cloud

device log from bitbar public cloud

Bonus Materials for XCTest and XCUITest

If you are looking for a way to quickly adopt and learn all the basics tips and tricks with XCTest/XCUITest, listen to Bitbar Webinar about Getting Started with XCTest/XCUITest for iOS App Testing.

More details and instructions on how to use XCTest and XCUITest for your test purposes and how to exercise those with the best practices can be found at Slideshare:

3 Ways to Build an Efficient Mobile Dev Team

Learn these 3 aspects to wisely turn your mobile development team into agile, efficient and productive mode.


By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.