Skip to main content

Configuring Your XCUITest Tests

Real Devices Only

saucectl relies on a YAML specification file to determine exactly which tests to run and how to run them. To customize saucectl to run your XCUITest tests, simply modify the properties of the YAML file accordingly. This page defines each of the configuration properties specific to running XCUITest tests.

Setting an Alternative Configuration File#

By default, saucectl looks for the config.yml file in the .sauce folder of your project root, but you can actually specify a different file, or if you are using multiple frameworks or need to configure different sets of tests to run separately, you may choose to have multiple configuration files that you can direct saucectl to reference as necessary.

Use the following configuration at runtime to direct saucectl to use any configuration file you choose:

saucectl run -c ./path/to/{config-file}.yml
YAML Required

While you can use multiple files of different names or locations to specify your configurations, each file must be a *.yml and follow the saucectl syntax. Our IDE Integrations (e.g. Visual Studio Code) can help you out by validating the YAML files and provide handy suggestions, so make sure to check them out!

Example Configuration#

.sauce/config.yml
loading...

Each of the properties supported for running XCUITest tests through saucectl is defined below.

apiVersion#

| REQUIRED | STRING |

Identifies the version of the underlying configuration schema. At this time, v1alpha is the only supported value.

apiVersion: v1alpha

kind#

| REQUIRED | STRING/ENUM |

Specifies which framework is associated with the automation tests configured in this specification.

kind: xcuitest

showConsoleLog#

| OPTIONAL | BOOLEAN |

Generates the console.log as local output and as a test asset in Sauce Labs for all tests. By default, console.log is only included in results for failed tests.

showConsoleLog: true

defaults#

| OPTIONAL | OBJECT |

Specifies any default settings for the project.

defaults:  timeout: 15m

timeout#

| OPTIONAL | DURATION |

Instructs how long (in ms, s, m, or h) saucectl should wait for each suite to complete. You can override this setting for individual suites using the timeout setting within the suites object. If not set, the default value is 0 (unlimited).

  timeout: 15m

sauce#

| OPTIONAL | OBJECT |

The parent property containing all settings related to how tests are run and identified in the Sauce Labs platform.

sauce:  region: eu-central-1    metadata:    tags:      - e2e      - release team      - other tag    build: Release $CI_COMMIT_SHORT_SHA  concurrency: 5

region#

| OPTIONAL | STRING/ENUM |

Specifies through which Sauce Labs data center tests will run. Valid values are: us-west-1 or eu-central-1.

  region: eu-central-1

metadata#

| OPTIONAL | OBJECT | VIRTUAL ONLY |

The set of properties that allows you to provide additional information about your project that helps distinguish it in the various environments in which it is used and reviewed, and also helps you apply filters to easily isolate tests based on metrics that are meaningful to you.

note

At this time, the metadata property is not supported for XCUITest because XCUITest is only supported for real device testing.

metadata:  build: RC 10.4.i  tags:    - e2e    - iPad    - beta    - featurex

concurrency#

| OPTIONAL | INTEGER |

Sets the maximum number of suites to execute at the same time. If the test defines more suites than the max, excess suites are queued and run in order as each suite completes.

caution

Set this value to equal or less than your Sauce concurrency allowance, as setting a higher value may result in jobs dropped by the server.

  concurrency: 5

Alternatively, you can override the file setting at runtime by setting the concurrency flag as an inline parameter of the saucectl run command:

saucectl run --ccy 5

retries#

| OPTIONAL | INTEGER |

Sets the number of times to retry a failed suite.

  retries: 1

Alternatively, you can override the file setting at runtime by setting the retries flag as an inline parameter of the saucectl run command:

saucectl run --retries 1

tunnel#

| OPTIONAL | OBJECT |

saucectl supports using Sauce Connect to establish a secure connection with Sauce Labs. To do so, launch a tunnel; then provide the name and owner (if applicable) in this property.

sauce:  tunnel:    name: your_tunnel_name    owner: tunnel_owner_username

name#

| OPTIONAL | STRING |

Identifies an active Sauce Connect tunnel to use for secure connectivity to the Sauce Labs cloud.

note

This property replaces the former id property, which is deprecated.

sauce:  tunnel:    name: your_tunnel_name

owner#

| OPTIONAL | STRING |

Identifies the Sauce Labs user who created the specified tunnel, which is required if the user running the tests did not create the tunnel.

note

This property replaces the former parent property, which is deprecated.

sauce:  tunnel:    name: your_tunnel_name    owner: tunnel_owner_username

reporters#

| OPTIONAL | OBJECT |

Configures additional reporting capabilities provided by saucectl.

reporters:  junit:    enabled: true    filename: saucectl-report.xml

artifacts#

| OPTIONAL | OBJECT |

Specifies how to manage test output, such as logs, videos, and screenshots.

artifacts:  cleanup: true  download:    when: always    match:      - junit.xml    directory: ./artifacts/

cleanup#

| OPTIONAL | BOOLEAN |

When set to true, all contents of the specified download directory are cleared before any new artifacts from the current test are downloaded.

  cleanup: true

download#

| OPTIONAL | OBJECT |

Specifies the settings related to downloading artifacts from tests run by saucectl.

  download:    when: always    match:      - junit.xml    directory: ./artifacts/

when#

| OPTIONAL | STRING |

Specifies when and under what circumstances to download artifacts. Valid values are:

  • always: Always download artifacts.
  • never: Never download artifacts.
  • pass: Download artifacts for passing suites only.
  • fail: Download artifacts for failed suites only.
    when: always

match#

| OPTIONAL | STRING/ARRAY |

Specifies which artifacts to download based on whether they match the name or file type pattern provided. Supports the wildcard character * (use quotes for best parsing results with wildcard).

  match:    - junit.xml    - "*.log"

directory#

| OPTIONAL | STRING |

Specifies the path to the folder location in which to download artifacts. A separate subdirectory is generated in this location for each suite for which artifacts are downloaded.

    directory: ./artifacts/

notifications#

| OPTIONAL | OBJECT |

Specifies how to set up automatic test result alerts.

notifications:  slack:    channels:      - "saucectl-tests"      - "xcuitest-results"    send: always

slack#

| OPTIONAL | OBJECT |

Specifies the settings related to sending tests result notifications through Slack. See Slack Integration for information about integrating your Sauce Labs account with your Slack workspace.

  slack:    channels: "saucectl-xcuitest"    send: always

channels#

| OPTIONAL | STRING/ARRAY |

The set of Slack channels to which the test result notifications are to be sent.

  slack:    channels:      - "saucectl-results"      - "xcuitest-team"    send: always

send#

| OPTIONAL | STRING |

Specifies when and under what circumstances to send notifications to specified Slack channels. Valid values are:

  • always: Send notifications for all test results.
  • never: Do not send any test result notifications.
  • pass: Send notifications for passing suites only.
  • fail: Send notifications for failed suites only.
  slack:    channels: "saucectl-xcuitest"    send: always

xcuitest#

| REQUIRED | OBJECT |

The parent property containing the details specific to the XCUITest project.

xcuitest:  app: ./apps/SauceLabs.Mobile.Sample.XCUITest.App.ipa  testApp: ./apps/SwagLabsMobileAppUITests-Runner.app  otherApps:    - ./apps/pre-installed-app1.ipa    - ./apps/pre-installed-app2.ipa

app#

| REQUIRED | STRING |

The path to the app. The property recognizes both .ipa and .app file types and supports expanded environment variables or an already uploaded test app reference.

  app: ./apps/xcuitest/SauceLabs.Mobile.Sample.XCUITest.App.ipa
  app: $APP
  app: storage:c78ec45e-ea3e-ac6a-b094-00364171addb
  app: storage:filename=SauceLabs.Mobile.Sample.XCUITest.App.ipa

testApp#

| REQUIRED | STRING |

The path to the testing app. The property recognizes both .ipa and .app file types and supports expanded environment variables.

  testApp: ./apps/SwagLabsMobileAppUITests-Runner.app
  testApp: $TEST_APP
  testApp: storage:11f421f0-30e3-23c2-9026-d73a205dcd38
  testApp: storage:filename=./apps/SwagLabsMobileAppUITests-Runner.app.ipa

otherApps#

| OPTIONAL | ARRAY | REAL DEVICES ONLY |

Set of up to seven apps to pre-install for your tests. You can upload an app from your local machine by specifying a filepath (relative location is {project-root}/apps/app1.ipa) or an expanded environment variable representing the path, or you can specify an app that has already been uploaded to Sauce Labs App Storage by providing the reference storage:<fileId> or storage:filename=<filename>.

note

Apps specified as otherApps inherit the configuration of the main app under test for Device Language, Device Orientation, and Proxy, regardless of any differences that may be applied through the Sauce Labs UI, because the settings are specific to the device under test. For example, if the dependent app is intended to run in landscape orientation, but the main app is set to portrait, the dependent app will run in portrait for the test, which may have unintended consequences.

  otherApps:    - ./apps/pre-installed-app1.ipa    - $PRE_INSTALLED_APP2    - storage:8d250fec-5ecb-535c-5d63-aed4da026293    - storage:filename=pre-installed-app3.ipa

suites#

| REQUIRED | OBJECT |

The set of properties providing details about the test suites to run. May contain multiple suite definitions. See the full example config for an illustration of multiple suite definitions.

Real Devices Only

At this time, saucectl does not support automated tests running on simulators.


name#

| REQUIRED | STRING |

The name of the test suite, which will be reflected in the results and related artifacts.

  - name: "saucy test"

timeout#

| OPTIONAL | DURATION |

Instructs how long saucectl should wait for the suite to complete, potentially overriding the default project timeout setting.

note

Setting 0 reverts to the value set in defaults.

  timeout: 15m

devices#

| REQUIRED | OBJECT |

The parent property that defines how to select real devices on which to run the test suite. You can request a specific device using its ID, or you can specify a set of criteria to choose the first available device that matches the specifications.

When an ID is specified, it supersedes the other settings.

devices:  - name: "iPhone 11"    platformVersion: "14.3"    options:      carrierConnectivity: true  - id: iPhone_11_14_5_real_us

id#

| OPTIONAL | STRING |

Request a specific device for this test suite by its ID. You can look up device IDs on device selection pages or by using our Get Devices API request.

        id: iPhone_11_14_5_real_us

name#

| OPTIONAL | STRING |

Find a device for this test suite that matches the device name or portion of the name, which may provide a larger pool of available devices of the type you want.

Use Complete Name
      - name: iPhone 11
Use Pattern Matching
        name: iPhone.*

platformVersion#

| OPTIONAL | STRING |

Request that the device matches a specific platform version.

        platformVersion: 14.3

options#

| OPTIONAL | OBJECT |

A parent property to further specify desired device attributes within the pool of devices that match the name and version criteria.


carrierConnectivity#

| OPTIONAL | BOOLEAN |

Request that the matching device is also connected to a cellular network.

  options:      carrierConnectivity: true

deviceType#

| OPTIONAL | STRING |

Request that the matching device is a specific type of device. Valid values are: ANY, TABLET, or PHONE.

  options:      deviceType: TABLET

private#

| OPTIONAL | BOOLEAN |

Request that the matching device is from your organization's private pool.

  options:      private: true

testOptions#

| OPTIONAL | OBJECT |

A set of parameters allowing you to provide additional details about which test class should be run for the suite and how to apply them.

testOptions:    class:      - SwagLabsMobileAppUITests.LoginTests/testSuccessfulLogin      - SwagLabsMobileAppUITests.LoginTests/testNoUsernameLogin      - SwagLabsMobileAppUITests.LoginTests    notClass:      - SwagLabsMobileAppUITests.SwagLabsFlow/testCompleteFlow

class#

| OPTIONAL | ARRAY |

Instructs saucectl to only run the specified classes for this test suite.

    class:      - SwagLabsMobileAppUITests.LoginTests/testSuccessfulLogin      - SwagLabsMobileAppUITests.LoginTests/testNoUsernameLogin      - SwagLabsMobileAppUITests.LoginTests

notClass#

| OPTIONAL | ARRAY |

Instructs saucectl to run all classes for the suite except those specified here.

    notClass:      - SwagLabsMobileAppUITests.SwagLabsFlow/testCompleteFlow

Advanced Configuration Considerations#

The configuration file is flexible enough to allow for any customizations and definitions that are required for any of the supported frameworks. The following sections describe some of the most common configurations.

Setting up a Proxy#

If you need to go through a proxy server, you can set it through the following variables:

  • HTTP_PROXY: Proxy to use to access HTTP websites
  • HTTPS_PROXY: Proxy to use to access HTTPS websites
PS> $Env:HTTP_PROXY=http://my.proxy.org:3128/PS> $Env:HTTPS_PROXY=http://my.proxy.org:3128/
$> export HTTP_PROXY=http://my.proxy.org:3128/$> export HTTPS_PROXY=http://my.proxy.org:3128/