TestOptions

@Incubating interface TestOptions
com.android.build.api.dsl.TestOptions

Options for running tests.

Summary

Public methods

abstract Unit

abstract Unit

abstract Unit
unitTests(action: UnitTestOptions.() -> Unit)

Options for controlling unit tests execution.

Properties

abstract Boolean

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

abstract NamedDomainObjectContainer<DeviceGroup>

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

abstract ExtensiblePolymorphicDomainObjectContainer<Device>

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

abstract EmulatorSnapshots

Configures Android Test Retention.

abstract String

Specifies whether to use on-device test orchestration.

abstract FailureRetention

abstract String?

Name of the reports directory.

abstract String?

Name of the results directory.

abstract UnitTestOptions

Options for controlling unit tests execution.

Public methods

emulatorSnapshots

abstract fun emulatorSnapshots(action: EmulatorSnapshots.() -> Unit): Unit

failureRetention

abstract fun failureRetention(action: FailureRetention.() -> Unit): Unit

Deprecated.

unitTests

abstract fun unitTests(action: UnitTestOptions.() -> Unit): Unit

Options for controlling unit tests execution.

Properties

animationsDisabled

abstract var animationsDisabled: Boolean

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

abstract val deviceGroups: NamedDomainObjectContainer<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

abstract val devices: ExtensiblePolymorphicDomainObjectContainer<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

abstract val emulatorSnapshots: EmulatorSnapshots

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

abstract var execution: String

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'
  }
}

failureRetention

abstract val failureRetention: FailureRetention

Deprecated.

reportDir

abstract var reportDir: String?

Name of the reports directory.

resultsDir

abstract var resultsDir: String?

Name of the results directory.

unitTests

abstract val unitTests: UnitTestOptions

Options for controlling unit tests execution.