HostTestBuilder

Added in 8.5.0

@Incubating
interface HostTestBuilder


Interface to turn on or off host tests. Host tests run on the development machine, UNIT_TEST_TYPE or SCREENSHOT_TEST_TYPE are examples of host tests.

Summary

Constants

const String

Host test type for default screenshot tests.

const String

Host test type for default unit tests.

Public properties

Boolean

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

Boolean

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

Boolean

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

String

Type of the HostTest, which can be 'UNIT_TEST_TYPE or SCREENSHOT_TEST_TYPE for HostTests created by AGP.

Constants

SCREENSHOT_TEST_TYPE

Added in 8.5.0
@Incubating
const val SCREENSHOT_TEST_TYPEString

Host test type for default screenshot tests.

UNIT_TEST_TYPE

Added in 8.5.0
@Incubating
const val UNIT_TEST_TYPEString

Host test type for default unit tests.

Public properties

enable

Added in 8.5.0
var enableBoolean

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 enableCodeCoverageBoolean

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 com.android.build.api.dsl.BuildType.enableUnitTestCoverage, it will be used for HostTestBuilder.UNIT_TEST_TYPE.

includeAndroidResources

Added in 9.0.0-alpha13
Deprecated in 9.0.0-alpha13
var includeAndroidResourcesBoolean

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 com.android.build.api.dsl.UnitTestOptions.isIncludeAndroidResources.

type

Added in 8.5.0
val typeString

Type of the HostTest, which can be 'UNIT_TEST_TYPE or SCREENSHOT_TEST_TYPE for HostTests created by AGP.