# HostTestBuilder

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


```
@Incubating
interface HostTestBuilder
```

<br />

*** ** * ** ***

Interface to turn on or off host tests. Host tests run on the development machine, `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#UNIT_TEST_TYPE()` or `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#SCREENSHOT_TEST_TYPE()` are examples of host tests.

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/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/variant/HostTestBuilder#SCREENSHOT_TEST_TYPE()` Host test type for default screenshot tests. |
| `const https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/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/variant/HostTestBuilder#UNIT_TEST_TYPE()` Host test type for default unit tests. |

| ### 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/variant/HostTestBuilder#enable()` Set to `true` if the variant's has any host tests, false otherwise. |
| `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/variant/HostTestBuilder#enableCodeCoverage()` **The getter for this property is deprecated.** Other plugins can change this value, it is not safe to read it at this stage, use \[HostTest.codeCoverageEnabled\] |
| `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/variant/HostTestBuilder#includeAndroidResources()` **The getter for this property is deprecated.** Other plugins can change this value, it is not safe to read it at this stage, use \[HostTest.androidResourcesIncluded\] |
| `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/variant/HostTestBuilder#type()` Type of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTest`, which can be '`https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#UNIT_TEST_TYPE()` or `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#SCREENSHOT_TEST_TYPE()` for `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTest`s created by AGP. |

## Constants

### SCREENSHOT_TEST_TYPE

Added in 8.5.0

```
@Incubating
const val SCREENSHOT_TEST_TYPE: String
```

Host test type for default screenshot tests.

### UNIT_TEST_TYPE

Added in 8.5.0

```
@Incubating
const val UNIT_TEST_TYPE: String
```

Host test type for default unit tests.

## Public properties

### enable

Added in 8.5.0

```
var enable: Boolean
```

Set to `true` if the variant's has any host tests, false otherwise.

Not setting this value relies on the AGP default behavior for this host test type.

### enableCodeCoverage

Added in 8.5.0 Deprecated in 8.5.0

```
var enableCodeCoverage: Boolean
```

> [!CAUTION]
> **The getter for this property is deprecated.**   
> Other plugins can change this value, it is not safe to read it at this stage, use \[HostTest.codeCoverageEnabled\]

Specifies host test code coverage data collection by configuring the JacocoPlugin.

When enabled, the Jacoco plugin is applied and coverage data is collected by the Jacoco plugin. This can avoid unwanted build time instrumentation required to collect coverage data from other test types such as connected tests.

If the value is initialized from the DSL `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/BuildType#enableUnitTestCoverage()`, it will be used for `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#UNIT_TEST_TYPE()`.

### includeAndroidResources

Added in 9.6.0-alpha03 Deprecated in 9.6.0-alpha03

```
var includeAndroidResources: Boolean
```

> [!CAUTION]
> **The getter for this property is deprecated.**   
> Other plugins can change this value, it is not safe to read it at this stage, use \[HostTest.androidResourcesIncluded\]

Enables host 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 host 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).

This field is initialized from the DSL `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/UnitTestOptions#isIncludeAndroidResources()`.

### type

Added in 8.5.0

```
val type: String
```

Type of the `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTest`, which can be '`https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#UNIT_TEST_TYPE()` or `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTestBuilder#SCREENSHOT_TEST_TYPE()` for `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/variant/HostTest`s created by AGP.