Class DefaultTestLauncher

    • Method Detail

      • withTests

        public TestLauncher withTests​(TestOperationDescriptor... testDescriptors)
        Description copied from interface: TestLauncher
        Adds tests to be executed by passing test descriptors received from a previous Gradle Run.
        Specified by:
        withTests in interface TestLauncher
        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: TestLauncher
        Adds tests to be executed by passing test descriptors received from a previous Gradle Run.
        Specified by:
        withTests in interface TestLauncher
        Parameters:
        descriptors - The OperationDescriptor defining one or more tests.
        Returns:
        this
      • withJvmTestClasses

        public TestLauncher withJvmTestClasses​(java.lang.String... classNames)
        Description copied from interface: TestLauncher

        Adds tests to be executed declared by class name.

        This method ignores tests defined in included builds.

        Specified by:
        withJvmTestClasses in interface TestLauncher
        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: TestLauncher

        Adds tests to be executed declared by class name.

        This method ignores tests defined in included builds.

        Specified by:
        withJvmTestClasses in interface TestLauncher
        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: TestLauncher

        Adds tests to be executed declared by class and method name.

        This method ignores tests defined in included builds.

        Specified by:
        withJvmTestMethods in interface TestLauncher
        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: TestLauncher

        Adds tests to be executed declared by class and methods name.

        This method ignores tests defined in included builds.

        Specified by:
        withJvmTestMethods in interface TestLauncher
        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: TestLauncher
        Adds 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:
        withTaskAndTestClasses in interface TestLauncher
        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: TestLauncher
        Adds 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:
        withTaskAndTestMethods in interface TestLauncher
        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: TestLauncher
        Configures 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 forkEvery property is set to 0.

        Specified by:
        debugTestsOn in interface TestLauncher
        Parameters:
        port - the target port where the test JVM expects the debugger
        Returns:
        this
      • run

        public void run()
        Description copied from interface: TestLauncher
        Executes the tests, blocking until complete.
        Specified by:
        run in interface TestLauncher
      • run

        public void run​(ResultHandler<? super java.lang.Void> handler)
        Description copied from interface: TestLauncher
        Starts 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. See TestLauncher.run() for a description of the various exceptions that the operation may fail with.

        Specified by:
        run in interface TestLauncher
        Parameters:
        handler - The handler to supply the result to.