gradle
8.5

# TestLauncher

interface TestLauncher : ConfigurableLauncher<T> (source)

A `TestLauncher` allows you to execute tests in a Gradle build.

If the target Gradle version is >=6.8 then you can use `TestLauncher` to execute tests from included builds. Test operation descriptors from included builds work out-of-the-box. You can target tasks from included builds by specifying the task identity path (i.e. `':included-build-name:subproject-name:taskName'`).

However, you cannot use the methods with included builds that don't specify the target test tasks (e.g. `withJvmTestClasses()` and `withJvmTestMethods()`). Those methods configure all test tasks in the root build only.

## Functions

addArguments
Link copied to clipboard
abstract fun addArguments(p: Array<String>): T
abstract fun addArguments(p: Array<String>): LongRunningOperation
addJvmArguments
Link copied to clipboard
abstract fun addJvmArguments(p: Array<String>): T
abstract fun addJvmArguments(p: Array<String>): LongRunningOperation
addProgressListener
Link copied to clipboard
abstract fun addProgressListener(p: ProgressListener): T
abstract fun addProgressListener(p: ProgressListener): LongRunningOperation
debugTestsOn
Link copied to clipboard
abstract fun debugTestsOn(port: Int): TestLauncher
Configures test JVM to run in debug mode.
forTasks
Link copied to clipboard
@Incubating
abstract fun forTasks(tasks: Array<String>): TestLauncher
Sets the tasks to be executed.
run
Link copied to clipboard
abstract fun run()
Executes the tests, blocking until complete.
abstract fun run(handler: ResultHandler<out Any>)
Starts executing the tests.
setColorOutput
Link copied to clipboard
abstract fun setColorOutput(p: Boolean): T
abstract fun setColorOutput(p: Boolean): LongRunningOperation
setEnvironmentVariables
Link copied to clipboard
abstract fun setEnvironmentVariables(p: Map<String, String>): T
abstract fun setEnvironmentVariables(p: Map<String, String>): LongRunningOperation
setJavaHome
Link copied to clipboard
abstract fun setJavaHome(p: File): T
abstract fun setJavaHome(p: File): LongRunningOperation
setJvmArguments
Link copied to clipboard
abstract fun setJvmArguments(p: Array<String>): T
abstract fun setJvmArguments(p: Array<String>): LongRunningOperation
setStandardError
Link copied to clipboard
abstract fun setStandardError(p: OutputStream): T
abstract fun setStandardError(p: OutputStream): LongRunningOperation
setStandardInput
Link copied to clipboard
abstract fun setStandardInput(p: InputStream): T
abstract fun setStandardInput(p: InputStream): LongRunningOperation
setStandardOutput
Link copied to clipboard
abstract fun setStandardOutput(p: OutputStream): T
abstract fun setStandardOutput(p: OutputStream): LongRunningOperation
withArguments
Link copied to clipboard
abstract fun withArguments(p: Array<String>): T
abstract fun withArguments(p: Array<String>): LongRunningOperation
withCancellationToken
Link copied to clipboard
abstract fun withCancellationToken(p: CancellationToken): T
abstract fun withCancellationToken(p: CancellationToken): LongRunningOperation
withJvmTestClasses
Link copied to clipboard
abstract fun withJvmTestClasses(testClasses: Iterable<String>): TestLauncher
abstract fun withJvmTestClasses(testClasses: Array<String>): TestLauncher
Adds tests to be executed declared by class name.
withJvmTestMethods
Link copied to clipboard
abstract fun withJvmTestMethods(testClass: String, methods: Iterable<String>): TestLauncher
Adds tests to be executed declared by class and methods name.
abstract fun withJvmTestMethods(testClass: String, methods: Array<String>): TestLauncher
Adds tests to be executed declared by class and method name.
withSystemProperties
Link copied to clipboard
abstract fun withSystemProperties(p: Map<String, String>): T
abstract fun withSystemProperties(p: Map<String, String>): LongRunningOperation
withTaskAndTestClasses
Link copied to clipboard
abstract fun withTaskAndTestClasses(task: String, testClasses: Iterable<String>): TestLauncher
Adds tests to be executed declared by the container task and the class name.
withTaskAndTestMethods
Link copied to clipboard
abstract fun withTaskAndTestMethods(task: String, testClass: String, methods: Iterable<String>): TestLauncher
Adds tests to be executed declared by the container task, class and method name.
withTests
Link copied to clipboard
abstract fun withTests(descriptors: Iterable<out TestOperationDescriptor>): TestLauncher
abstract fun withTests(descriptors: Array<TestOperationDescriptor>): TestLauncher
Adds tests to be executed by passing test descriptors received from a previous Gradle Run.
withTestsFor
Link copied to clipboard
@Incubating
abstract fun withTestsFor(testSpec: Action<TestSpecs>): TestLauncher
Adds tests to be executed declared using a fine-grained test selection API.