Skip to main content

Espresso and XCUITest on Sauce Labs

Sauce Labs uses its framework agnostic test orchestrator saucectl to execute Espresso and XCUITest tests based on one or more configuration files that instruct saucectl to run your tests exactly the way you specify. Results get published in your Sauce Labs account, where you can compare 30 days of results across different environments and frameworks all in one view.

What You'll Need

  • A Sauce Labs account (Log in or sign up for a free trial license)
  • Your Sauce Labs Username and Access Key
  • Your Espresso apps and files for real devices and/or emulators
  • Your XCUITest apps and files for real devices (automated tests for simulators are not supported at this time)

Installation & Setup

saucectl can execute both Espresso and XCUITest tests, so the set up steps are the same regardless of which framework you are using.

1. Install saucectl

Begin by installing the saucectl CLI so it has access to your local project.

sudo sh -c 'curl -L https://saucelabs.github.io/saucectl/install | bash -s -- -b /usr/local/bin'
Required Minimum Versions

XCUITest for Simulators is in Beta and requires saucectl version 0.1xx.0 or later. If your current version is older, you must upgrade to the most recent one.

2. Check out the demo repositories

Clone or download the Espresso and/or XCUITest example repos, as applicable to your project, to obtain the saucectl directory structure and example files for use as templates.

  1. Generate a credentials file that saucectl can reference to authenticate your CLI commands.
    saucectl configure
  2. Enter your Sauce Labs SAUCE_USERNAME and SAUCE_ACCESS_KEY at the prompts.
  3. saucectl creates a credentials.yml file in a .sauce folder of your home directory.
Use Environment Variables

You can set your Sauce Labs credentials as environment variables instead of generating a credentials.yml, if you prefer. In systems where both sets of credentials exist, environment variable values are prioritized.

4. Configure your test parameters

Each demo repo includes a sample config.yml file (in the <root>/.sauce directory) that is preconfigured to run the example test, which is also included in the repo.

Modify the config.yml file according to the configuration documentation for Espresso and XCUITest.

Alternative Config Files

You can create multiple configuration files to support different frameworks or different test setups and then reference the applicable configuration file at runtime using the CLI command:

saucectl run -c ./path/to/<configFile>.yml

5. Run your tests

Use the saucectl CLI run command to execute your tests using the parameters you have specified in your configuration file.

saucectl run

You can optionally set runtime parameters in the CLI, but keep in mind that saucectl looks for settings in your config file first, so if you use the CLI flags to specify settings that are also set in your config file, the CLI flag values are ignored.