TestOptions

@Incubating interface TestOptions


Options for running tests.

Summary

Public functions

Unit
Unit

This function is deprecated. Renamed to emulatorSnapshots

Unit

Configures Gradle Managed Devices for use in testing with the Unified test platform.

Unit

Options for controlling unit tests execution.

Public properties

Boolean

Disables animations during instrumented tests you run from the command line.

NamedDomainObjectContainer<DeviceGroup>

List of DeviceGroups that can be run through connected check, using the Unified Test Platform.

ExtensiblePolymorphicDomainObjectContainer<Device>

List of test devices for this project for use with the Unified Test Platform

EmulatorSnapshots

Configures Android Test Retention.

String

Specifies whether to use on-device test orchestration.

FailureRetention

This property is deprecated. Renamed to emulatorSnapshots

ManagedDevices

Configures Gradle Managed Devices for use in testing with the Unified test platform.

String?

Name of the reports directory.

String?

Name of the results directory.

UnitTestOptions

Options for controlling unit tests execution.

Public functions

emulatorSnapshots

fun emulatorSnapshots(action: (@ExtensionFunctionType EmulatorSnapshots.() -> Unit)?): Unit

failureRetention

fun failureRetention(action: (@ExtensionFunctionType FailureRetention.() -> Unit)?): Unit

managedDevices

fun managedDevices(action: (@ExtensionFunctionType ManagedDevices.() -> Unit)?): Unit

Configures Gradle Managed Devices for use in testing with the Unified test platform.

unitTests

fun unitTests(action: (@ExtensionFunctionType UnitTestOptions.() -> Unit)?): Unit

Options for controlling unit tests execution.

Public properties

animationsDisabled

val animationsDisabledBoolean

Disables animations during instrumented tests you run from the command line.

If you set this property to true, running instrumented tests with Gradle from the command line executes am instrument with the --no-window-animation flag. By default, this property is set to false.

This property does not affect tests that you run using Android Studio. To learn more about running tests from the command line, see Test from the Command Line.

deviceGroups

val deviceGroupsNamedDomainObjectContainer<DeviceGroup>

List of DeviceGroups that can be run through connected check, using the Unified Test Platform.

DeviceGroups with individual devices are added automatically, with the same name of the individual device.

These APIs are experimental and may change without notice.

devices

val devicesExtensiblePolymorphicDomainObjectContainer<Device>

List of test devices for this project for use with the Unified Test Platform

These APIs are experimental and may change without notice.

emulatorSnapshots

val emulatorSnapshotsEmulatorSnapshots

Configures Android Test Retention.

Android Test Retention automatically takes emulator snapshots on test failures. It can only work with Unified Test Platform (UTP).

android {
testOptions {
emulatorSnapshots {
enableForTestFailures true
maxSnapshotsForTestFailures 2
compressSnapshots false
}
}
}

execution

val executionString

Specifies whether to use on-device test orchestration.

If you want to use Android Test Orchestrator you need to specify "ANDROID_TEST_ORCHESTRATOR", as shown below. By default, this property is set to "HOST", which disables on-device orchestration.

android {
testOptions {
execution 'ANDROID_TEST_ORCHESTRATOR'
}
}

since 3.0.0

failureRetention

val failureRetentionFailureRetention

managedDevices

val managedDevicesManagedDevices

Configures Gradle Managed Devices for use in testing with the Unified test platform.

reportDir

val reportDirString?

Name of the reports directory.

resultsDir

val resultsDirString?

Name of the results directory.

unitTests

val unitTestsUnitTestOptions

Options for controlling unit tests execution.