Class DefaultTestLauncher
- java.lang.Object
-
- org.gradle.tooling.internal.consumer.AbstractLongRunningOperation<DefaultTestLauncher>
-
- org.gradle.tooling.internal.consumer.DefaultTestLauncher
-
- All Implemented Interfaces:
ConfigurableLauncher<TestLauncher>,LongRunningOperation,TestLauncher
public class DefaultTestLauncher extends AbstractLongRunningOperation<DefaultTestLauncher> implements TestLauncher
-
-
Field Summary
-
Fields inherited from class org.gradle.tooling.internal.consumer.AbstractLongRunningOperation
connectionParameters, operationParamsBuilder
-
-
Constructor Summary
Constructors Constructor Description DefaultTestLauncher(AsyncConsumerActionExecutor connection, ConnectionParameters parameters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TestLauncherdebugTestsOn(int port)Configures test JVM to run in debug mode.protected DefaultTestLaunchergetThis()voidrun()Executes the tests, blocking until complete.voidrun(ResultHandler<? super java.lang.Void> handler)Starts executing the tests.TestLauncherwithJvmTestClasses(java.lang.Iterable<java.lang.String> testClasses)Adds tests to be executed declared by class name.TestLauncherwithJvmTestClasses(java.lang.String... classNames)Adds tests to be executed declared by class name.TestLauncherwithJvmTestMethods(java.lang.String testClass, java.lang.Iterable<java.lang.String> methods)Adds tests to be executed declared by class and methods name.TestLauncherwithJvmTestMethods(java.lang.String testClass, java.lang.String... methods)Adds tests to be executed declared by class and method name.TestLauncherwithTaskAndTestClasses(java.lang.String task, java.lang.Iterable<java.lang.String> testClasses)Adds tests to be executed declared by the container task and the class name.TestLauncherwithTaskAndTestMethods(java.lang.String task, java.lang.String testClass, java.lang.Iterable<java.lang.String> methods)Adds tests to be executed declared by the container task, class and method name.TestLauncherwithTests(java.lang.Iterable<? extends TestOperationDescriptor> descriptors)Adds tests to be executed by passing test descriptors received from a previous Gradle Run.TestLauncherwithTests(TestOperationDescriptor... testDescriptors)Adds tests to be executed by passing test descriptors received from a previous Gradle Run.-
Methods inherited from class org.gradle.tooling.internal.consumer.AbstractLongRunningOperation
addArguments, addArguments, addJvmArguments, addJvmArguments, addProgressListener, addProgressListener, addProgressListener, addProgressListener, copyFrom, getConsumerOperationParameters, rationalizeInput, rationalizeInput, setColorOutput, setEnvironmentVariables, setJavaHome, setJvmArguments, setJvmArguments, setStandardError, setStandardInput, setStandardOutput, withArguments, withArguments, withCancellationToken, withInjectedClassPath
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.gradle.tooling.ConfigurableLauncher
addArguments, addArguments, addJvmArguments, addJvmArguments, addProgressListener, addProgressListener, addProgressListener, addProgressListener, setColorOutput, setEnvironmentVariables, setJavaHome, setJvmArguments, setJvmArguments, setStandardError, setStandardInput, setStandardOutput, withArguments, withArguments, withCancellationToken
-
-
-
-
Constructor Detail
-
DefaultTestLauncher
public DefaultTestLauncher(AsyncConsumerActionExecutor connection, ConnectionParameters parameters)
-
-
Method Detail
-
getThis
protected DefaultTestLauncher getThis()
- Specified by:
getThisin classAbstractLongRunningOperation<DefaultTestLauncher>
-
withTests
public TestLauncher withTests(TestOperationDescriptor... testDescriptors)
Description copied from interface:TestLauncherAdds tests to be executed by passing test descriptors received from a previous Gradle Run.- Specified by:
withTestsin interfaceTestLauncher- Parameters:
testDescriptors- The OperationDescriptor defining one or more tests.- Returns:
- this
-
withTests
public TestLauncher withTests(java.lang.Iterable<? extends TestOperationDescriptor> descriptors)
Description copied from interface:TestLauncherAdds tests to be executed by passing test descriptors received from a previous Gradle Run.- Specified by:
withTestsin interfaceTestLauncher- Parameters:
descriptors- The OperationDescriptor defining one or more tests.- Returns:
- this
-
withJvmTestClasses
public TestLauncher withJvmTestClasses(java.lang.String... classNames)
Description copied from interface:TestLauncherAdds tests to be executed declared by class name.
This method ignores tests defined in included builds.
- Specified by:
withJvmTestClassesin interfaceTestLauncher- Parameters:
classNames- The class names of the tests to be executed.- Returns:
- this
-
withJvmTestClasses
public TestLauncher withJvmTestClasses(java.lang.Iterable<java.lang.String> testClasses)
Description copied from interface:TestLauncherAdds tests to be executed declared by class name.
This method ignores tests defined in included builds.
- Specified by:
withJvmTestClassesin interfaceTestLauncher- Parameters:
testClasses- The class names of the tests to be executed.- Returns:
- this
-
withJvmTestMethods
public TestLauncher withJvmTestMethods(java.lang.String testClass, java.lang.String... methods)
Description copied from interface:TestLauncherAdds tests to be executed declared by class and method name.
This method ignores tests defined in included builds.
- Specified by:
withJvmTestMethodsin interfaceTestLauncher- Parameters:
testClass- The name of the class containing the methods to execute.methods- The names of the test methods to be executed.- Returns:
- this
-
withJvmTestMethods
public TestLauncher withJvmTestMethods(java.lang.String testClass, java.lang.Iterable<java.lang.String> methods)
Description copied from interface:TestLauncherAdds tests to be executed declared by class and methods name.
This method ignores tests defined in included builds.
- Specified by:
withJvmTestMethodsin interfaceTestLauncher- Parameters:
testClass- The name of the class containing the methods to execute.methods- The names of the test methods to be executed.- Returns:
- this
-
withTaskAndTestClasses
public TestLauncher withTaskAndTestClasses(java.lang.String task, java.lang.Iterable<java.lang.String> testClasses)
Description copied from interface:TestLauncherAdds tests to be executed declared by the container task and the class name.Note: These tests are ignored for target Gradle version earlier than 6.1
- Specified by:
withTaskAndTestClassesin interfaceTestLauncher- Parameters:
task- The path of the target task.testClasses- The class names of the tests to be executed.- Returns:
- this
-
withTaskAndTestMethods
public TestLauncher withTaskAndTestMethods(java.lang.String task, java.lang.String testClass, java.lang.Iterable<java.lang.String> methods)
Description copied from interface:TestLauncherAdds tests to be executed declared by the container task, class and method name.Note: These tests are ignored for target Gradle version earlier than 6.1
- Specified by:
withTaskAndTestMethodsin interfaceTestLauncher- Parameters:
task- The path of the target task.testClass- The name of the class containing the methods to execute.methods- The names of the test methods to be executed.- Returns:
- this
-
debugTestsOn
public TestLauncher debugTestsOn(int port)
Description copied from interface:TestLauncherConfigures test JVM to run in debug mode.When called, the forked test JVM is launched with the following argument:
-agentlib:jdwp=transport=dt_socket,server=n,suspend=n,address=localhost:<port>
This means the test JVM expects a debugger at the specified port that uses a socket listening connector. If the debugger is not present then the test execution will fail.Invoking this method adjusts the test task to launch only one JVM. More specifically, the parallel execution gets disabled and the
forkEveryproperty is set to 0.- Specified by:
debugTestsOnin interfaceTestLauncher- Parameters:
port- the target port where the test JVM expects the debugger- Returns:
- this
-
run
public void run()
Description copied from interface:TestLauncherExecutes the tests, blocking until complete.- Specified by:
runin interfaceTestLauncher
-
run
public void run(ResultHandler<? super java.lang.Void> handler)
Description copied from interface:TestLauncherStarts executing the tests. This method returns immediately, and the result is later passed to the given handler.If the operation fails, the handler's
ResultHandler.onFailure(GradleConnectionException)method is called with the appropriate exception. SeeTestLauncher.run()for a description of the various exceptions that the operation may fail with.- Specified by:
runin interfaceTestLauncher- Parameters:
handler- The handler to supply the result to.
-
-