Device allocation in Tradefed

When starting a test (for example, an instrumentation test), it might need a device to be able to run properly. Or the test (such as some Java unit tests) might not need a device at all. Still others or might even need multi-devices (like phone + watch tests). In all those cases, the Device Manager is responsible for allocating the required devices to the test so it runs properly. We call this phase the device allocation or device selection step.

The allocation is driven by DeviceSelectionOptions that allow a test to declare any properties it needs from a device, including:

  • Battery level
  • Device type
  • Product type
  • Serial number

Use real devices

This is the default setting that will be allocated to all tests that don't specify any device properties. A physical random device marked AVAILABLE will be picked and assigned to the test.

Use no devices

When no devices are needed by the test, it can specify --null-device or -n on its command line, or <option name="null-device" value="true" /> in its configuration XML. This allocates a stub placeholder NullDevice that represents no device was allocated.