# TestOptions

[View Source](https://cs.android.com/search?q=file:com/android/build/api/dsl/TestOptions.kt+class:com.android.build.api.dsl.TestOptions) Added in 4.2.0


```
interface TestOptions
```

<br />

*** ** * ** ***

Options for running tests.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@https://docs.gradle.org/current/javadoc/org/gradle/api/Incubating.html https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#emulatorControl(kotlin.Function1)(action: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/EmulatorControl.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@https://docs.gradle.org/current/javadoc/org/gradle/api/Incubating.html https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#managedDevices(kotlin.Function1)(action: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ManagedDevices.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Configures Gradle Managed Devices for use in testing with the Unified test platform. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#targetSdk(kotlin.Function1)(action: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TargetSdkSpec.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Specifies value that overrides all aspects regarding target sdk for tests in libraries. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#unitTests(kotlin.Function1)(action: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/UnitTestOptions.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Options for controlling unit tests execution. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#animationsDisabled()` Disables animations during instrumented tests you run from the command line. |
| `https://docs.gradle.org/current/javadoc/org/gradle/api/NamedDomainObjectContainer.html<https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/BackupTestSuite>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#backupTests()` Configures the specialized Backup TestSuite designed for Automated Backup \& Restore Testing. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/EmulatorControl` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#emulatorControl()` Configures Android Emulator Grpc Access |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#execution()` Specifies whether to use on-device test orchestration. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#instrumentInPrivateComputeCore()` Whether to enable Private Compute Core on-device environment during instrumentation. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ManagedDevices` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#managedDevices()` Configures Gradle Managed Devices for use in testing with the Unified test platform. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#reportDir()` Name of the reports' directory. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#resultsDir()` Name of the results' directory. |
| `https://docs.gradle.org/current/javadoc/org/gradle/api/NamedDomainObjectContainer.html<https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ScreenshotTestSuite>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#screenshotTests()` Configures the specialized Screenshot TestSuite designed for Compose Preview Screenshot Testing. |
| `https://docs.gradle.org/current/javadoc/org/gradle/api/PolymorphicDomainObjectContainer.html<https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/AgpTestSuite>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#suites()` **This property is deprecated.** Use customSuites |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html?` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#targetSdk()` Specifies value that overrides target sdk version number for tests in libraries. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#targetSdkPreview()` Specifies value that overrides target sdk preview number for tests in libraries. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/UnitTestOptions` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#unitTests()` Options for controlling unit tests execution. |

## Public functions

### emulatorControl

Added in 8.1.0

```
@Incubating
fun emulatorControl(action: EmulatorControl.() -> Unit): Unit
```

### managedDevices

Added in 7.2.0

```
@Incubating
fun managedDevices(action: ManagedDevices.() -> Unit): Unit
```

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

### targetSdk

Added in 9.6.0-alpha03

```
fun targetSdk(action: TargetSdkSpec.() -> Unit): Unit
```

Specifies value that overrides all aspects regarding target sdk for tests in libraries.

See `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TargetSdkSpec` for available options. Important: Setting this value will cause an error for application and other module types.

### unitTests

Added in 4.2.0

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

Options for controlling unit tests execution.

## Public properties

### animationsDisabled

Added in 4.2.0

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

### backupTests

Added in 9.6.0-alpha03

```
val backupTests: NamedDomainObjectContainer<BackupTestSuite>
```

Configures the specialized Backup TestSuite designed for Automated Backup \& Restore Testing.

### emulatorControl

Added in 8.1.0

```
val emulatorControl: EmulatorControl
```

Configures Android Emulator Grpc Access

Android Emulator Grpc Access will make it possible to interact with the emulator over gRPC

```
android {
    emulatorControl {
      enable true
      secondsValid 180
      allowedEndpoints.addAll(
          "/android.emulation.control.EmulatorController/getStatus",
          "/android.emulation.control.EmulatorController/getVmState")
    }
}
```

### execution

Added in 4.2.0

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

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

since 3.0.0

### instrumentInPrivateComputeCore

Added in 9.6.0-alpha03

```
var instrumentInPrivateComputeCore: Boolean
```

Whether to enable Private Compute Core on-device environment during instrumentation.

### managedDevices

Added in 7.2.0

```
val managedDevices: ManagedDevices
```

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

### reportDir

Added in 4.2.0

```
var reportDir: String?
```

Name of the reports' directory.

### resultsDir

Added in 4.2.0

```
var resultsDir: String?
```

Name of the results' directory.

### screenshotTests

Added in 9.6.0-alpha03

```
val screenshotTests: NamedDomainObjectContainer<ScreenshotTestSuite>
```

Configures the specialized Screenshot TestSuite designed for Compose Preview Screenshot Testing.

### suites

Added in 9.6.0-alpha03 Deprecated in 9.6.0-alpha03

```
val suites: PolymorphicDomainObjectContainer<AgpTestSuite>
```

> [!CAUTION]
> **This property is deprecated.**   
> Use customSuites

Deprecated, use `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/TestOptions#customSuites()`

### targetSdk

Added in 8.2.0

```
var targetSdk: Int?
```

Specifies value that overrides target sdk version number for tests in libraries. Default value is set to minSdk. Important: Setting this value will cause an error for application and other module types.

### targetSdkPreview

Added in 8.2.0

```
var targetSdkPreview: String?
```

Specifies value that overrides target sdk preview number for tests in libraries. Default value is empty. Important: Setting this value will cause an error for application and other module types.

### unitTests

Added in 4.2.0

```
val unitTests: UnitTestOptions
```

Options for controlling unit tests execution.