TestSuite

Added in 9.1.0-alpha02

interface TestSuite : Named


Model for test suites.

This object is accessible on subtypes of Variant that implement HasTestSuites, via HasTestSuites.suites.

Summary

Public functions

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

Configures the test tasks for this test target.

Public properties

Property<Boolean>

Turns on or off the code coverage support.

JUnitEngineSpec

Return the JUnitEngineSpec for this test suite.

Collection<TestSuiteSourceSet>

Return the list of sourcesets associated with this test suite.

Map<StringTestSuiteTarget>

Return the list of TestSuiteTarget for this test suite in this variant.

Inherited functions

From org.gradle.api.Named

Public functions

configureTestTasks

Added in 9.1.0-alpha02
fun configureTestTasks(action: Test.(context: TestTaskContext) -> Unit): Unit

Configures the test tasks for this test target.

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

The configuration block can use the action's context parameter to disambiguate between each org.gradle.api.tasks.testing.Test task instance.

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

Parameters
action: Test.(context: TestTaskContext) -> Unit

a block to configure the org.gradle.api.tasks.testing.Test 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: Test.(context: TestTaskContext) -> Unit

to configure the org.gradle.api.tasks.testing.Test task.

Public properties

codeCoverage

Added in 9.1.0-alpha02
val codeCoverageProperty<Boolean>

Turns on or off the code coverage support.

Initialized from the corresponding TestSuiteBuilder.codeCoverage

junitEngineSpec

Added in 9.1.0-alpha02
val junitEngineSpecJUnitEngineSpec

Return the JUnitEngineSpec for this test suite.

sources

Added in 9.1.0-alpha02
val sourcesCollection<TestSuiteSourceSet>

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

The returned Collection of TestSuiteSourceSet is not specific to this variant but to the related TestSuite instance, which may apply to multiple variants as specified through the com.android.build.api.dsl.AgpTestSuite.targetVariants API.

targets

Added in 9.1.0-alpha02
val targetsMap<StringTestSuiteTarget>

Return the list of TestSuiteTarget for this test suite in this variant.