Run iOS tests with Marathon Cloud

Evgenii Matsiuk (Eugene Matsyuk)
MarathonLabs
Published in
5 min readJun 20, 2023

--

Marathon Cloud revolutionizes your app testing experience. The platform provides infinite virtual devices and will automatically shard, sort, distribute, and retry your tests, allowing all tests to be completed in a maximum of 15 minutes. The first 50 hours are free!

This article will guide you on how to conduct your initial iOS tests using Marathon Cloud.

Sign up / Sign in

Go to the main page and click on the “Sign up / Sign in” button:

Pass the Login/Registration flow:

Dashboard

Once you have completed the “Sign up / Sign in” process, you will be required to create a team and select the platforms on which you intend to operate:

At last, the dashboard will be visible:

Build the application and testing .app bundles

Before initiating the testing process for your iOS application, you’ll need to create two .app bundles: one for the application that's being tested, and another for the tests themselves. Typically, debug variants are utilized for this purpose.

Imagine that our project is called "Sample". For this scenario, the code snippet below demonstrates how the building command should be presented:

# file structure
# |
# |--home
# |--john
# |--sample <== you are here
# |--sample <== it's your application
# ...
# |--sample.xcodeproj

xcodebuild build-for-testing \
-project sample.xcodeproj \
-scheme sample \
-destination 'platform=iOS Simulator,name=iPhone 14,OS=16.1' \
-derivedDataPath ./build

Be sure to note the relative paths of applications, as they will be required for running the tests. In the context of our example, involving the debug build, these files can be located at the following paths:

  • Application: /home/john/sample/build/Build/Products/Debug-iphonesimulator/sample.app
  • Test APK: /home/john/sample/build/Build/Products/Debug-iphonesimulator/sampleUITests-Runner.app

One important thing to note is that *.app files are actually folders in disguise. To transfer them, it’s necessary to convert these bundles into .ipa format or standard zip archives:

# file structure
# |
# |--home
# |--john
# |--sample <== you are here
# |--build <== derivedData folder
# |--sample <== it's your application
# ...
# |--sample.xcodeproj
cd build/Build/Products/Debug-iphonesimulator
# convert to zip archive in this example
zip -r sample.zip sample.app
zip -r sampleUITests-Runner.zip sampleUITests-runner.app

Further, we will use these files:

  • Application: /home/john/sample/build/Build/Products/Debug-iphonesimulator/sample.zip
  • Test APK: /home/john/sample/build/Build/Products/Debug-iphonesimulator/sampleUITests-Runner.zip

Run tests with UI

To initiate your tests, the easiest method is to utilize the UI Dashboard. Initially, select the “New Run” button situated at the top-right of the screen:

A dialog box will appear:

Here are the next steps you should take in this box:

  • Select the IOS tab.
  • Enter a Title of your choice.
  • Choose the App file. In accordance with the previous example, the application archive can be found at this path: /home/john/sample/build/Build/Products/Debug-iphonesimulator/sample.zip.
  • Select the Test app file. As per the same example, the test app archive is located at this path: /home/john/sample/build/Build/Products/Debug-iphonesimulator/sampleUITests-Runner.zip.
  • Click on the RUN button.

Congratulations on beginning your first test run at Marathon Cloud:

Watching results

Your run should be completed within a timeframe of 15 minutes. Once finished, you can view the reports by clicking on the designated button:

The overview of your test run will appear:

To investigate the causes of any test failures, kindly proceed with the following steps:

Run tests with CLI

There is a way to run your tests with CLI using marathon-cloud-cli. The full documentation of this CLI is available on the Readme page. In this chapter, we are going to consider the basic steps to run your tests.

Install

The installation can be performed using Homebrew. Here’s how to add the MarathonLabs repository:

$brew tap malinskiy/tap  -platform Android

Next, install the Marathon Cloud CLI:

$brew install malinskiy/tap/marathon-cloud

Alternatively, you can download prebuilt binaries for Windows, Linux, or MacOS from the Release page.

API Key

Token creation and management are available on the Tokens page. Generate a token and save it somewhere safe for the next step.

Execution

Now you can start running your tests. Let’s consider the example app described above. Use the following command to execute the CLI with the necessary parameters:

marathon-cloud run ios \
--api-key generated_api_key \
--application /home/john/sample/build/Build/Products/Debug-iphonesimulator/sample.zip \
--test-application /home/john/sample/build/Build/Products/Debug-iphonesimulator/sampleUITests-Runner.zip

--

--