TestComponent

Added in 7.0.0

interface TestComponent : Component

Known direct subclasses
DeviceTest

Model for Device Test components that contains build-time properties

HostTest

Model for Host Test components that contains build-time properties.

UnitTest

Component for unit tests

Known indirect subclasses
AndroidTest

Model for Android Test components that contains build-time properties

UnitTest

This interface is deprecated. Use the com.android.build.api.variant package


Model for test components that contains build-time properties.

These components are attached to a main component (Variant), and accessed via them.

androidComponents {
onVariants(selector().all()) { variant: ApplicationVariant ->
variant.androidTest?.apply {
....
}
variant.unitTest?.apply {
....
}
}
}

Not all subtype of Variant will have access to all sub-types of TestComponent, this is handled via HasUnitTest, and HasDeviceTests.

The test components are also part of Variant.nestedComponents

Summary

Public properties

MapProperty<StringString>

MapProperty of the test component's manifest placeholders.

Inherited functions

From com.android.build.api.variant.Component
String
@Incubating
computeTaskName(action: String, subject: String)

Utility method to create unique task name for component.

Unit

This function is deprecated. Will be removed in v9.0, use the instrumentation block.

Unit
<ParamT : InstrumentationParameters> transformClassesWith(
    classVisitorFactoryImplClass: Class<AsmClassVisitorFactory<ParamT>>,
    scope: InstrumentationScope,
    instrumentationParamsConfig: (ParamT) -> Unit
)

This function is deprecated. Will be removed in v9.0, use the instrumentation block.

Inherited properties

From com.android.build.api.variant.Component
Configuration

Access to the variant's annotation processor Configuration; for example, the debugAnnotationProcessor Configuration for the debug variant.

Artifacts

Access to the variant's buildable artifacts for build customization.

FileCollection

Access to the variant's compile classpath.

Configuration

Access to the variant's compile Configuration; for example, the debugCompileClasspath Configuration for the debug variant.

Boolean

Whether the produced artifacts will be debuggable

Instrumentation

Access to the variant's instrumentation options.

JavaCompilation

Access to the variant's java compilation options.

LifecycleTasks

Provides access to the LifecycleTasks created for this component.

Provider<String>

The namespace of the generated R and BuildConfig classes.

Configuration

Access to the variant's runtime Configuration; for example, the debugRuntimeClasspath Configuration for the debug variant.

Sources

Access to variant's source files.

From com.android.build.api.variant.ComponentIdentity
String?

Build type name.

String?

The multi-flavor name of the variant.

String

Component's name.

List<Pair<StringString>>

List of flavor names.

Public properties

manifestPlaceholders

Added in 7.4.1
val manifestPlaceholdersMapProperty<StringString>

MapProperty of the test component's manifest placeholders.

Placeholders are organized with a key and a value. The value is a String that will be used as is in the merged manifest.

Returns
MapProperty<StringString>

the MapProperty with keys as String