Skip to main content

Configuring Your XCUITest Tests

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

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 $X_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, but is coming soon.

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 identifier in this property.

Choose the Correct Tunnel Identifier

When you launch a tunnel, you can accept the tunnel identifier name that Sauce Labs generates for your account (e.g., {SL-username}_tunnel_id) or specify a name in the launch command:

bin/sc -u {SL-username} -k {SL-access_key} -i {tunnel_identifier}

This is the identifier saucectl expects as the id property, even though the Sauce Labs UI refers to this values as the Tunnel Name.

 tunnel:    id: your_tunnel_id

env#

| OPTIONAL | OBJECT |

A property containing one or more environment variables that are global for all tests suites in this configuration. Expanded environment variables are supported. Values set in this global property will overwrite values set for the same environment variables set at the suite level.

  env:    hello: world    my_var: $MY_VAR

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:  download:    when: always    match:      - junit.xml    directory: ./artifacts/

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/

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 application. The property recognizes both .ipa and .app file types and supports expanded environment variables.

  app: ./apps/xcuitest/SauceLabs.Mobile.Sample.XCUITest.App.ipa
  app: $APP

testApp#

| REQUIRED | STRING |

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

  testApp: ./apps/SwagLabsMobileAppUITests-Runner.app
  testApp: $TEST_APP

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: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"

env#

| OPTIONAL | OBJECT |

A property containing one or more environment variables that may be referenced in the tests for this suite. Expanded environment variables are supported. Values set here will be overwritten by values set in the global env property.

  env:    hello: world    my_var: $MY_VAR

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/