# TestOptions

# TestOptions

<br />

```
@Incubating interface TestOptions
```

<br />

*** ** * ** ***

Options for running tests.

## Summary

|                                                                                                                                                                                                                                                                                                                            ### Public functions                                                                                                                                                                                                                                                                                                                             ||
|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [emulatorSnapshots](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#emulatorSnapshots(kotlin.Function1))`(action: (@`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` `[EmulatorSnapshots](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/EmulatorSnapshots)`.() `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)?)`                                                                          |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | ~~[failureRetention](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#failureRetention(kotlin.Function1))~~`(action: (@`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` `[FailureRetention](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/FailureRetention)`.() `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)?)` **This function is deprecated.**Renamed to emulatorSnapshots             |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [managedDevices](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#managedDevices(kotlin.Function1))`(action: (@`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` `[ManagedDevices](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ManagedDevices)`.() `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)?)` Configures Gradle Managed Devices for use in testing with the Unified test platform. |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [unitTests](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#unitTests(kotlin.Function1))`(action: (@`[ExtensionFunctionType](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-extension-function-type/index.html)` `[UnitTestOptions](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/UnitTestOptions)`.() `->` `[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)`)?)` Options for controlling unit tests execution.                                                |

|                                                                                                                                                                                                                                        ### Public properties                                                                                                                                                                                                                                        ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                                                                                                                                                                                | [animationsDisabled](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#animationsDisabled()) Disables animations during instrumented tests you run from the command line.       |
| [NamedDomainObjectContainer](https://docs.gradle.org/current/javadoc/org/gradle/api/NamedDomainObjectContainer.html)`<`[DeviceGroup](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/DeviceGroup)`>`                       | [deviceGroups](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#deviceGroups()) List of DeviceGroups that can be run through connected check, using the Unified Test Platform. |
| [ExtensiblePolymorphicDomainObjectContainer](https://docs.gradle.org/current/javadoc/org/gradle/api/ExtensiblePolymorphicDomainObjectContainer.html)`<`[Device](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/Device)`>` | [devices](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#devices()) List of test devices for this project for use with the Unified Test Platform                             |
| [EmulatorSnapshots](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/EmulatorSnapshots)                                                                                                                                     | [emulatorSnapshots](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#emulatorSnapshots()) Configures Android Test Retention.                                                   |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                                                                                                                                                                                  | [execution](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#execution()) Specifies whether to use on-device test orchestration.                                               |
| [FailureRetention](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/FailureRetention)                                                                                                                                       | [failureRetention](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#failureRetention()) **This property is deprecated.**Renamed to emulatorSnapshots                           |
| [ManagedDevices](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/ManagedDevices)                                                                                                                                           | [managedDevices](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#managedDevices()) Configures Gradle Managed Devices for use in testing with the Unified test platform.       |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                               | [reportDir](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#reportDir()) Name of the reports directory.                                                                       |
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`?`                                                                                                                                                                               | [resultsDir](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#resultsDir()) Name of the results directory.                                                                     |
| [UnitTestOptions](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/UnitTestOptions)                                                                                                                                         | [unitTests](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#unitTests()) Options for controlling unit tests execution.                                                        |

## Public functions

### emulatorSnapshots

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

### failureRetention

```
fun [failureRetention](https://developer.android.com/reference/tools/gradle-api/7.2/com/android/build/api/dsl/TestOptions#failureRetention(kotlin.Function1))(action: (@ExtensionFunctionType FailureRetention.() -> Unit)?): Unit
```
| **This function is deprecated.**   
Renamed to emulatorSnapshots  

### 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 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](https://d.android.com/studio/test/command-line.html).  

### deviceGroups

```
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

```
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

```
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).  

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

### execution

```
val execution: String
```

Specifies whether to use on-device test orchestration.

If you want to[use Android Test Orchestrator](https://developer.android.com/training/testing/junit-runner.html#using-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.  

```scdoc
android {
  testOptions {
    execution 'ANDROID_TEST_ORCHESTRATOR'
  }
}
```

since 3.0.0  

### failureRetention

```
val failureRetention: FailureRetention
```
| **This property is deprecated.**   
Renamed to emulatorSnapshots  

### managedDevices

```
val managedDevices: ManagedDevices
```

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

### reportDir

```
val reportDir: String?
```

Name of the reports directory.  

### resultsDir

```
val resultsDir: String?
```

Name of the results directory.  

### unitTests

```
val unitTests: UnitTestOptions
```

Options for controlling unit tests execution.