TestSuite

Added in 9.0.0-alpha07

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

JUnitEngineSpec

Returns the JUnitEngineSpec for 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-alpha07
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

junitEngineSpec

Added in 9.0.0-alpha07
val junitEngineSpecJUnitEngineSpec

Returns the JUnitEngineSpec for this test suite.

targets

Added in 9.0.0-alpha07
val targetsMap<StringTestSuiteTarget>

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