When your test code is running in App Center Test there are some environment variables available to the test script that you can use in your tests when using certain test frameworks.
Calabash, Appium and Xamarin.UITest use a client/server approach. The test script is the "client" and sends HTTP requests to a "server" that is running with the app under test which ultimately invokes code on the mobile device.
These environment variables are only available for Calabash, Appium and Xamarin.UITest and only to the test script code. They are not available to the application under test. They are set in App Center Test but not when you run locally.
Espresso and XCUITest use a model where the test and the app both run on the mobile device so these environment variables are not available in those test frameworks.
This is always set to 1 when when the tests are running in App Center Test.
XTC_APP_ENDPOINT (Android Only)
This variable exposes a secure port on the device that allows other services to communicate with the application. This is useful for applications that embedded their own HTTP servers in an application and have a need to interact with the app outside of the test framework.
This variable combines both the operating system and the device name.
This is a string in the range of 0 to N-1, where N is the number of devices the test is run on. This variable is useful in situations where the same test is being run in parallel on multiple devices. The value of
XTC_DEVICE_INDEX is unique for each test script executing on a specific device. For additional discussion of this topic, see: Handling Concurrent Database Changes During Tests.
This variable holds the name of the device running the test.
This variable holds the name of the device operating system running the test.
This variable holds the name of the of language used to run the test. It defaults to en.
The platform under test, will be either android or ios.
Sample Xamarin.UITest Code
var xamarintestcloud = Environment.GetEnvironmentVariable("XAMARIN_TEST_CLOUD");
var xtcappendpoint = Environment.GetEnvironmentVariable("XTC_APP_ENDPOINT");
var xtcdevice = Environment.GetEnvironmentVariable("XTC_DEVICE");
var xtcdeviceindex = Environment.GetEnvironmentVariable("XTC_DEVICE_INDEX");
var xtcdevicename = Environment.GetEnvironmentVariable("XTC_DEVICE_NAME");
var xtcdeviceos = Environment.GetEnvironmentVariable("XTC_DEVICE_OS");
var xtclang = Environment.GetEnvironmentVariable("XTC_LANG");
var xtcplatform = Environment.GetEnvironmentVariable("XTC_PLATFORM");
Test log output in App Center Test
XTC_DEVICE=Google Pixel 2 XL (8.1.0)
XTC_DEVICE_NAME=Google Pixel 2 XL