# 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.3.3


```
interface TestSuite : Named
```

<br />

*** ** * ** ***

Model for test suites.

This object is accessible on subtypes of `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/Variant` that implement `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/HasTestSuites`, via `https://developer.android.com/reference/tools/gradle-api/9.3/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.3/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.3/com/android/build/api/dsl/TestTaskContext) -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Configures the test tasks for this test target. |
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html<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/TestSuite#instrumentationRunner(com.android.build.api.variant.TestSuiteSourceSet.TestApk)(source: https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestSuiteSourceSet.TestApk)` The instrumentationRunner to use to run the tests. |

| ### 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.3/com/android/build/api/variant/TestSuite#codeCoverage()` Turns on or off the code coverage support. |
| `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/JUnitEngineSpec` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestSuite#junitEngineSpec()` Return the `https://developer.android.com/reference/tools/gradle-api/9.3/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.3/com/android/build/api/variant/TestSuiteSourceSet>` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestSuite#sources()` Return the list of sourcesets 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.3/com/android/build/api/variant/TestSuiteTarget>` | `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestSuite#targets()` Return the list of `https://developer.android.com/reference/tools/gradle-api/9.3/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.3.3

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

Configures 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.3/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.3/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 : ``` 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.3/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. |

### instrumentationRunner

Added in 9.3.3

```
@Incubating
fun instrumentationRunner(source: TestSuiteSourceSet.TestApk): Provider<String>
```

The instrumentationRunner to use to run the tests.

| Returns |
|---|---|
| `https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Provider.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html>` | the instrumentation test runner name |

## Public properties

### codeCoverage

Added in 9.3.3

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

Turns on or off the code coverage support.

Initialized from the corresponding TestSuiteBuilder.codeCoverage

### junitEngineSpec

Added in 9.3.3

```
val junitEngineSpec: JUnitEngineSpec
```

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

### sources

Added in 9.3.3

```
val sources: Collection<TestSuiteSourceSet>
```

Return the list of sourcesets associated with this test suite. Sourcesets are added through the DSL using one of the following methods:

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

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

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

The returned `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestSuiteSourceSet` is not specific to this variant but to the related `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/variant/TestSuite` instance, which may apply to multiple variants as specified through the `https://developer.android.com/reference/tools/gradle-api/9.3/com/android/build/api/dsl/AgpTestSuite#targetVariants()` API.

### targets

Added in 9.3.3

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

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