# TestSuite

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


```
interface TestSuite : Named
```

<br />

*** ** * ** ***

Model for test suites.

This object is accessible on subtypes of `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/Variant` that implement `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/HasTestSuites`, via `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/HasTestSuites#suites()`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuite#configureTestTasks(kotlin.Function2)(action: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html.(context: https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/dsl/TestTaskContext) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Configure the test tasks for this test target. |

| ### Public properties |
|---|---|
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html>` | `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuite#codeCoverage()` Turns on or off the code coverage support. |
| `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/JUnitEngineSpec` | `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuite#junitEngineSpec()` Returns the `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/JUnitEngineSpec` for this test suite. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuiteSource>` | `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuite#sources()` Returns the list of sources associated with this test suite. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuiteTarget>` | `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuite#targets()` Returns the list of `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuiteTarget` for this test suite in this variant. |

| ### Inherited functions |
|---|
| From [org.gradle.api.Named](https://docs.gradle.org/current/javadoc/org/gradle/api/Named.html) |---|---| | `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html` | `https://docs.gradle.org/current/javadoc/org/gradle/api/Named.html#getName--()` | |

## Public functions

### configureTestTasks

Added in 9.0.1

```
fun configureTestTasks(action: Test.(context: TestTaskContext) -> Unit): Unit
```

Configure the test tasks for this test target.

There can be one to many instances of `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` tasks for a particular test suite target. For instance, if the test suite targets more than one device, AGP may decide to create one `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` instance per device.

The configuration block can use the `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuite#configureTestTasks(kotlin.Function2)`'s context parameter to disambiguate between each `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` task instance.

Do not make assumption about how AGP decides to allocate `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` task instances per device, as each AGP version can potentially change it in future release, always use the context object to determine what the `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` task applies to.

| Parameters |
|---|---|
| `action: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html.(context: https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/dsl/TestTaskContext) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | a block to configure the `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` tasks associated with this test suite target. Example : ```gdscript androidComponents { onVariants { variant -> variant.testSuites.forEach { testSuite -> testSuite.configureTestTask { testTask -> testTask.beforeTest { descriptor -> println("Running test: " + descriptor) } } } } } ``` |
| `action: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html.(context: https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/dsl/TestTaskContext) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | to configure the `https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html` task. |

## Public properties

### codeCoverage

Added in 9.0.1

```
val codeCoverage: Property<Boolean>
```

Turns on or off the code coverage support.

Initialized from the corresponding TestSuiteBuilder.codeCoverage

### junitEngineSpec

Added in 9.0.1

```
val junitEngineSpec: JUnitEngineSpec
```

Returns the `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/JUnitEngineSpec` for this test suite.

### sources

Added in 9.0.1

```
val sources: Collection<TestSuiteSource>
```

Returns the list of sources associated with this test suite. Sources are added through the DSL using one of the following methods :

- `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/dsl/AgpTestSuite#assets(kotlin.Function1)`

- `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/dsl/AgpTestSuite#hostJar(kotlin.Function1)`

- `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/dsl/AgpTestSuite#testApk(kotlin.Function1)`

### targets

Added in 9.0.1

```
val targets: Map<String, TestSuiteTarget>
```

Returns the list of `https://developer.android.com/reference/tools/gradle-api/9.0/com/android/build/api/variant/TestSuiteTarget` for this test suite in this variant.