This content is now maintained here: https://docs.microsoft.com/appcenter/test-cloud/environment-variables
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.
Environment Variables
XAMARIN_TEST_CLOUD
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.
XTC_DEVICE
This variable combines both the operating system and the device name.
XTC_DEVICE_INDEX
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.
XTC_DEVICE_NAME
This variable holds the name of the device running the test.
XTC_DEVICE_OS
This variable holds the name of the device operating system running the test.
XTC_LANG
This variable holds the name of the of language used to run the test. It defaults to en.
XTC_PLATFORM
The platform under test, will be either android or ios.
Sample Xamarin.UITest Code
var xamarintestcloud = Environment.GetEnvironmentVariable("XAMARIN_TEST_CLOUD");
Console.WriteLine($"XAMARIN_TEST_CLOUD={xamarintestcloud}");
var xtcappendpoint = Environment.GetEnvironmentVariable("XTC_APP_ENDPOINT");
Console.WriteLine($"XTC_APP_ENDPOINT={xtcappendpoint}");
var xtcdevice = Environment.GetEnvironmentVariable("XTC_DEVICE");
Console.WriteLine($"XTC_DEVICE={xtcdevice}");
var xtcdeviceindex = Environment.GetEnvironmentVariable("XTC_DEVICE_INDEX");
Console.WriteLine($"XTC_DEVICE_INDEX={xtcdeviceindex}");
var xtcdevicename = Environment.GetEnvironmentVariable("XTC_DEVICE_NAME");
Console.WriteLine($"XTC_DEVICE_NAME={xtcdevicename}");
var xtcdeviceos = Environment.GetEnvironmentVariable("XTC_DEVICE_OS");
Console.WriteLine($"XTC_DEVICE_OS={xtcdeviceos}");
var xtclang = Environment.GetEnvironmentVariable("XTC_LANG");
Console.WriteLine($"XTC_LANG={xtclang}");
var xtcplatform = Environment.GetEnvironmentVariable("XTC_PLATFORM");
Console.WriteLine($"XTC_PLATFORM={xtcplatform}");
Test log output in App Center Test
XAMARIN_TEST_CLOUD=1
XTC_APP_ENDPOINT=http://devicehost151.prod:37777/proxy2/token-c059c5c6-37cc-4400-9038-96d1d342ed6e/
XTC_DEVICE=Google Pixel 2 XL (8.1.0)
XTC_DEVICE_INDEX=0
XTC_DEVICE_NAME=Google Pixel 2 XL
XTC_DEVICE_OS=8.1.0
XTC_LANG=en
XTC_PLATFORM=android