# TestComponent

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


```
interface TestComponent : Component
```

<br />

Known direct subclasses [DeviceTest](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/DeviceTest), [HostTest](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/HostTest), [UnitTest](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/UnitTest)

|---|---|
| `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/DeviceTest` | Model for Device Test components that contains build-time properties |
| `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/HostTest` | Model for Host Test components that contains build-time properties. |
| `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/UnitTest` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component` for unit tests |

Known indirect subclasses [AndroidTest](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/AndroidTest), [UnitTest](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/component/UnitTest)

|---|---|
| `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/AndroidTest` | Model for Android Test components that contains build-time properties |
| `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/component/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 (`https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Variant`), and accessed via them.

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

Not all subtype of `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Variant` will have access to all sub-types of `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestComponent`, this is handled via `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/HasUnitTest`, and `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/HasDeviceTests`.

The test components are also part of `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Variant#nestedComponents()`

## Summary

| ### Public properties |
|---|---|
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/MapProperty.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestComponent#manifestPlaceholders()` `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/MapProperty.html` of the test component's manifest placeholders. |

| ### Inherited functions |
|---|
| From [com.android.build.api.variant.Component](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component) |---|---| | `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.3/com/android/build/api/variant/Component#computeTaskName(kotlin.String,kotlin.String)(action: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, subject: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Utility method to create unique task name for component. | | `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.3/com/android/build/api/variant/Component#configureJavaCompileTask(kotlin.Function1)(action: (https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/compile/JavaCompile.html) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Runs an action to configure Components's java compilation `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/compile/JavaCompile.html` task. | | `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` | `@https://docs.gradle.org/current/javadoc/org/gradle/api/Incubating.html https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#getResolvableConfiguration(kotlin.String)(sourceSetConfigurationsAffix: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Access to the component's resolvable configuration corresponding to the source set configurations added via `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/AndroidComponentsExtension#addSourceSetConfigurations(kotlin.String)`. | |

| ### Inherited properties |
|---|
| From [com.android.build.api.variant.Component](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component) |---|---| | `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#annotationProcessorConfiguration()` Access to the variant's annotation processor `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html`; for example, the debugAnnotationProcessor `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` for the debug variant. | | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/artifact/Artifacts` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#artifacts()` Access to the variant's buildable artifacts for build customization. | | `https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileCollection.html` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#compileClasspath()` Access to the variant's compile classpath. | | `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#compileConfiguration()` Access to the variant's compile `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html`; for example, the debugCompileClasspath `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` for the debug variant. | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#debuggable()` Whether the produced artifacts will be debuggable | | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Instrumentation` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#instrumentation()` Access to the variant's instrumentation options. | | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/JavaCompilation?` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#javaCompilation()` Access to the variant's java compilation options. | | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/LifecycleTasks` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#lifecycleTasks()` Provides access to the `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/LifecycleTasks` created for this component. | | `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#namespace()` The namespace of the generated R and BuildConfig classes. | | `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#runtimeConfiguration()` Access to the variant's runtime `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html`; for example, the debugRuntimeClasspath `https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Configuration.html` for the debug variant. | | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Sources` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Component#sources()` Access to variant's source files. | |
| From [com.android.build.api.variant.ComponentIdentity](https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/ComponentIdentity) |---|---| | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/ComponentIdentity#buildType()` Build type name. | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/ComponentIdentity#flavorName()` The multi-flavor name of the variant. | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/ComponentIdentity#name()` Component's name. | | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-pair/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>>` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/ComponentIdentity#productFlavors()` List of flavor names. | |

## Public properties

### manifestPlaceholders

Added in 7.4.0

```
val manifestPlaceholders: MapProperty<String, String>
```

`https://docs.gradle.org/current/javadoc/org/gradle/api/provider/MapProperty.html` of the test component's manifest placeholders.

Placeholders are organized with a key and a value. The value is a `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` that will be used as is in the merged manifest.

| Returns |
|---|---|
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/MapProperty.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | the `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/MapProperty.html` with keys as `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` |