Class AbstractTestTask

    • Constructor Detail

      • AbstractTestTask

        public AbstractTestTask()
    • Method Detail

      • getProgressLoggerFactory

        @Inject
        protected org.gradle.internal.logging.progress.ProgressLoggerFactory getProgressLoggerFactory()
      • getTextOutputFactory

        @Inject
        protected org.gradle.internal.logging.text.StyledTextOutputFactory getTextOutputFactory()
      • getHostnameLookup

        @Inject
        protected org.gradle.internal.nativeintegration.network.HostnameLookup getHostnameLookup()
      • getBuildOperationRunner

        @Inject
        protected org.gradle.internal.operations.BuildOperationRunner getBuildOperationRunner()
      • getBuildOperationExecutor

        @Inject
        protected org.gradle.internal.operations.BuildOperationExecutor getBuildOperationExecutor()
      • getInstantiator

        @Inject
        protected org.gradle.internal.reflect.Instantiator getInstantiator()
      • getListenerManager

        @Inject
        protected org.gradle.internal.event.ListenerManager getListenerManager()
      • createTestExecuter

        protected abstract org.gradle.api.internal.tasks.testing.TestExecuter<? extends org.gradle.api.internal.tasks.testing.TestExecutionSpec> createTestExecuter()
        Creates test executer. For internal use only.
        Since:
        4.4
      • createTestExecutionSpec

        protected abstract org.gradle.api.internal.tasks.testing.TestExecutionSpec createTestExecutionSpec()
        Creates test execution specification. For internal use only.
        Since:
        4.4
      • getBinaryResultsDirectory

        @OutputDirectory
        public DirectoryProperty getBinaryResultsDirectory()
        Returns the root directory property for the test results in internal binary format.
        Since:
        4.4
      • addTestOutputListener

        public void addTestOutputListener​(TestOutputListener listener)
        Registers a output listener with this task. Quicker way of hooking into output events is using the onOutput(groovy.lang.Closure) method.
        Parameters:
        listener - The listener to add.
      • getIgnoreFailures

        @Internal
        public boolean getIgnoreFailures()
        Specifies whether the build should break when the verifications performed by this task fail.
        Specified by:
        getIgnoreFailures in interface VerificationTask
        Returns:
        false, when the build should break on failure, true when the failures should be ignored.
      • setIgnoreFailures

        public void setIgnoreFailures​(boolean ignoreFailures)
        Specifies whether the build should break when the verifications performed by this task fail.
        Specified by:
        setIgnoreFailures in interface VerificationTask
        Parameters:
        ignoreFailures - false to break the build on failure, true to ignore the failures. The default is false.
      • onOutput

        public void onOutput​(Closure closure)
        Adds a closure to be notified when output from the test received. A TestDescriptor and TestOutputEvent instance are passed to the closure as a parameter.
         apply plugin: 'java'
        
         test {
            onOutput { descriptor, event ->
                if (event.destination == TestOutputEvent.Destination.StdErr) {
                    logger.error("Test: " + descriptor + ", error: " + event.message)
                }
            }
         }
         
        Parameters:
        closure - The closure to call.
      • beforeSuite

        public void beforeSuite​(Closure closure)

        Adds a closure to be notified before a test suite is executed. A TestDescriptor instance is passed to the closure as a parameter.

        This method is also called before any test suites are executed. The provided descriptor will have a null parent suite.

        Parameters:
        closure - The closure to call.
      • afterSuite

        public void afterSuite​(Closure closure)

        Adds a closure to be notified after a test suite has executed. A TestDescriptor and TestResult instance are passed to the closure as a parameter.

        This method is also called after all test suites are executed. The provided descriptor will have a null parent suite.

        Parameters:
        closure - The closure to call.
      • beforeTest

        public void beforeTest​(Closure closure)
        Adds a closure to be notified before a test is executed. A TestDescriptor instance is passed to the closure as a parameter.
        Parameters:
        closure - The closure to call.
      • afterTest

        public void afterTest​(Closure closure)
        Adds a closure to be notified after a test has executed. A TestDescriptor and TestResult instance are passed to the closure as a parameter.
        Parameters:
        closure - The closure to call.
      • getTestLogging

        @Internal
        public TestLoggingContainer getTestLogging()
        Allows to set options related to which test events are logged to the console, and on which detail level. For example, to show more information about exceptions use:
         apply plugin: 'java'
        
         test.testLogging {
             exceptionFormat "full"
         }
         
        For further information see TestLoggingContainer.
        Returns:
        this
      • testLogging

        public void testLogging​(@DelegatesTo(TestLoggingContainer.class)
                                Closure closure)
        Allows configuring the logging of the test execution, for example log eagerly the standard output, etc.
         apply plugin: 'java'
        
         // makes the standard streams (err and out) visible at console when running tests
         test.testLogging {
            showStandardStreams = true
         }
         
        Parameters:
        closure - configure closure
      • testLogging

        public void testLogging​(Action<? super TestLoggingContainer> action)
        Allows configuring the logging of the test execution, for example log eagerly the standard output, etc.
         apply plugin: 'java'
        
         // makes the standard streams (err and out) visible at console when running tests
         test.testLogging {
            showStandardStreams = true
         }
         
        Parameters:
        action - configure action
        Since:
        3.5
      • executeTests

        public void executeTests()
      • getNoMatchingTestErrorReasons

        @Internal
        protected java.util.List<java.lang.String> getNoMatchingTestErrorReasons()
        Returns the reasons for no matching test error.
        Since:
        4.5
      • setTestNameIncludePatterns

        public AbstractTestTask setTestNameIncludePatterns​(java.util.List<java.lang.String> testNamePattern)
        Sets the test name patterns to be included in execution. Classes or method names are supported, wildcard '*' is supported. For more information see the user guide chapter on testing. For more information on supported patterns see TestFilter
      • reports

        public TestTaskReports reports​(Closure closure)
        Configures the reports that this task potentially produces.
        Specified by:
        reports in interface Reporting<TestTaskReports>
        Parameters:
        closure - The configuration
        Returns:
        The reports that this task potentially produces
      • getFilter

        public TestFilter getFilter()
        Allows filtering tests for execution.
        Returns:
        filter object
        Since:
        1.10