TestSuite

Added in 9.0.0-alpha13

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)

Configure the test tasks for this test target.

Public properties

Property<Boolean>

Turns on or off the code coverage support.

JUnitEngineSpec

Returns the JUnitEngineSpec for this test suite.

Collection<TestSuiteSource>

Returns the list of sources associated with this test suite.

Map<StringTestSuiteTarget>

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

Inherited functions

From org.gradle.api.Named

Public functions

configureTestTasks

Added in 9.0.0-alpha13
fun configureTestTasks(action: Test.(context: TestTaskContext) -> Unit): Unit

Configure 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.0.0-alpha13
val codeCoverageProperty<Boolean>

Turns on or off the code coverage support.

Initialized from the corresponding TestSuiteBuilder.codeCoverage

junitEngineSpec

Added in 9.0.0-alpha13
val junitEngineSpecJUnitEngineSpec

Returns the JUnitEngineSpec for this test suite.

sources

Added in 9.0.0-alpha13
val sourcesCollection<TestSuiteSource>

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

targets

Added in 9.0.0-alpha13
val targetsMap<StringTestSuiteTarget>

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