# UnitTestOptions

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


```
interface UnitTestOptions
```

<br />

*** ** * ** ***

Options for controlling unit tests execution.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `@org.gradle.declarative.dsl.model.annotations.HiddenInDefinition https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/UnitTestOptions#all(kotlin.Function1)(configAction: (https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Configures all unit testing tasks. |

| ### 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/UnitTestOptions#isIncludeAndroidResources()` Enables unit tests to use Android resources, assets, and manifests. |
| `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/UnitTestOptions#isReturnDefaultValues()` Whether unmocked methods from android.jar should throw exceptions or return default values (i.e. zero or null). |

## Public functions

### all

Added in 4.2.0

```
@org.gradle.declarative.dsl.model.annotations.HiddenInDefinition
fun all(configAction: (Test) -> Unit): Unit
```

Configures all unit testing tasks.

See `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` for available options.

Inside the closure you can check the name of the task to configure only some test tasks, e.g.

```
android {
    testOptions {
        unitTests.all {
            if (it.name == 'testDebug') {
                systemProperty 'debug', 'true'
            }
        }
    }
}
```

since 1.2.0

## Public properties

### isIncludeAndroidResources

Added in 4.2.0

```
var isIncludeAndroidResources: Boolean
```

Enables unit tests to use Android resources, assets, and manifests.

If you set this property to `true`, the plugin performs resource, asset, and manifest merging before running your unit tests. Your tests can then inspect a file called `com/android/tools/test_config.properties` on the classpath, which is a Java properties file with the following keys:

`android_resource_apk`: the path to the APK-like zip file containing merged resources, which includes all the resources from the current subproject and all its dependencies.

`android_merged_assets`: the path to the directory containing merged assets. The merged assets directory contains assets from the current subproject and it dependencies.

`android_merged_manifest`: the path to the merged manifest file. Only app subprojects have the manifest merged from their dependencies. Library subprojects do not include manifest components from their dependencies.

`android_custom_package`: the package name (namespace) of the final R class.

Note that the paths above are relative paths (relative to the current project directory, not the root project directory).

since 3.0.0

### isReturnDefaultValues

Added in 4.2.0

```
var isReturnDefaultValues: Boolean
```

Whether unmocked methods from android.jar should throw exceptions or return default values (i.e. zero or null).

See [Test Your App](https://developer.android.com/studio/test/index.html) for details.

since 1.1.0