Skip to end of metadata
Go to start of metadata

In addition to passing test configuration options to Sauce Runner for Virtual Devices through the command line, you can also create a .yml configuration file for your tests, and have the runner execute based on the test parameters you set in the file. 

General Usage

JAVA_HOME=$(/usr/libexec/java_home --version 8) java -jar runner.jar config --path <path to config.yml> --apikey <apikey>

Example Sauce Runner Configuration File for XCUITest

This example of the .yml configuration file for using Sauce Runner for Virtual Devices with XCUITest includes all the required options, uses the --devices option to select devices based on both static and dynamic allocation, and the --testsToRun option to set a specific set of tests to run against a device. 

---
# Test framework: "xcuitest" or "espresso"
testFramework: xcuitest

# Path to the app's .ipa or .app.
app: ./SampleApp.ipa

# Path to the test runner app's .ipa or .app.
test: ./SampleAppUITests-Runner.ipa

# Path where XML test reports will be saved.
xmlFolder: ./

# Define a list of devices on which the tests should be executed.
devices:

# Device 1 example: minimal configuration. 
# Only specify a DC (either EU or US).
- datacenter: EU

# Device 2 example: Static Allocation.
- datacenter: US
  # Specify a device descriptor for static allocation f.ex. iPhone_8_real_us.
  device: iPhone_8_real_us

  # set test name (optional)
  testname: MyTestName2

# Device 3 example: Dynamic Allocation.
- datacenter: US
  # Specify a device name or regex for dynamic allocation: 'iPhone 5', 'iPad.*', etc.
  deviceNameQuery: iPhone 5

  # Platform Version for a dynamic device query. f.ex '9' for all Devices 
  # with major version 9 and arbitrary minor versions or '9.3.3' for a more 
  # specific version.
  platformVersion: 11.4
 
  # set test name
  testname: MyTestName3

  # Optional parameters, set to true to enable.
  # phoneOnly: false 
  # tabletOnly: false
  # privateDevicesOnly: false

# Device 4 example: Running subset of tests.
  # Data center to run tests in (either EU or US).
- datacenter: EU

  # set test name (optional)
  testname: MyTestName4
  # Provide a list of test cases or test classes. If you want to run all tests 
  # of a class provide only the class name and if you want to run a specific 
  # method of a class provide the class name and method name. 
  testsToRun:
  - testClass: SampleTestCase
  - testClass: SampleTestCase2
    testMethod: testItWorks

Example Sauce Runner Configuration File for Espresso

This example of the .yml configuration file for using Sauce Runner for Virtual Devices with Espresso includes all the required options, uses the --devices option to select devices based on both static and dynamic allocation, and the --testsToRun option to set a specific set of tests to run against a device. 

---
testFramework: espresso
# Path to the app's .apk
app: ./SampleApp.apk

# Path to the test runner app's .apk
test: ./SampleAppUITests-Runner.apk

# Path where XML test reports will be saved.
xmlFolder: ./

# Define a list of devices on which the tests should be executed.
devices:

# Device 1 example: minimal configuration. 
# Only specify a DC (either EU or US).
- datacenter: EU

# Device 2 example: Static Allocation.
- datacenter: US
  # Specify a device descriptor for static allocation f.ex. Samsung_Galaxy_S8_real.
  device: Samsung_Galaxy_S8_real

  # set test name (optional)
  testname: MyTestName3

# Device 3 example: Dynamic Allocation.
- datacenter: US
  # Specify a device name or regex for dynamic allocation: 'Samsung Galaxy S7', 'Samsung Galaxy.*', etc.
  deviceNameQuery: Samsung Galaxy S7
  # Platform Version for a dynamic device query. f.ex '7' for all Devices 
  # with major version 7 and arbitrary minor versions or '7.1.2' for a more 
  # specific version.
  platformVersion: 7.1
  # Optional parameters, set to true to enable.
  # phoneOnly: false 
  # tabletOnly: false
  # privateDevicesOnly: false
 
  # set test name (optional)
  testname: MyTestName3

# Device 4 example: Running subset of tests.
  # Data center to run tests in (either EU or US).
- datacenter: EU

  # set test name (optional)
  testname: MyTestName4

  # Provide a list of test options to esspresso. 
  # The key-value pairs supported by espresso are documented here: https://developer.android.com/studio/test/command-line#AMOptionsSyntax
  # In the example below the test would execute all test methods defined in the class com.example.android.TestClassA and
  # the test method 'methodName' defined in com.example.android.TestClassB
  envs:
  - key: class
    value: com.example.android.TestClassA
  - key: class
    value: com.example.android.TestClassB#methodName

Uploading Espresso and XCUITest to Storage Before Execution

Example for uploading an iOS test runner:

curl -u "username:APIKEY" -X POST https://app.testobject.com:443/api/storage/upload -H "Content-Type: application/octet-stream" -H "App-Type: XCUITEST" --data-binary @/path/to/XCUITests-Runner.ipa

Example for uploading an Android test runner:

 

curl -u "username:APIKEY" -X POST https://app.testobject.com:443/api/storage/upload -H "Content-Type: application/octet-stream" -H "App-Type: ANDROID_INSTRUMENTATION_TEST" --data-binary @/path/to/androidTest.apk
  • No labels