Package org.gradle.api.tasks.testing
Class AbstractTestTask
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.testing.AbstractTestTask
- All Implemented Interfaces:
- Comparable<Task>,- org.gradle.api.internal.DynamicObjectAware,- org.gradle.api.internal.IConventionAware,- org.gradle.api.internal.TaskInternal,- Named,- ExtensionAware,- Reporting<TestTaskReports>,- Task,- VerificationTask,- Configurable<Task>
@DisableCachingByDefault(because="Abstract super-class, not to be instantiated directly")
public abstract class AbstractTestTask
extends org.gradle.api.internal.ConventionTask
implements VerificationTask, Reporting<TestTaskReports>
Abstract class for all test tasks.
 
- Support for test listeners
- Support for reporting
- Support for report linking in the console output
Note: This abstract class is not intended for implementation by build script or plugin authors.
- Since:
- 4.4
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.gradle.api.TaskTask.Namer
- 
Field SummaryFields inherited from interface org.gradle.api.TaskTASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddTestListener(TestListener listener) Registers a test listener with this task.voidaddTestOutputListener(TestOutputListener listener) Registers a output listener with this task.voidafterSuite(Closure closure) Adds a closure to be notified after a test suite has executed.voidAdds a closure to be notified after a test has executed.voidbeforeSuite(Closure closure) Adds a closure to be notified before a test suite is executed.voidbeforeTest(Closure closure) Adds a closure to be notified before a test is executed.protected abstract org.gradle.api.internal.tasks.testing.TestExecuter<? extends org.gradle.api.internal.tasks.testing.TestExecutionSpec> Creates test executer.protected abstract org.gradle.api.internal.tasks.testing.TestExecutionSpecCreates test execution specification.voidReturns the root directory property for the test results in internal binary format.protected org.gradle.internal.operations.BuildOperationExecutorprotected org.gradle.internal.operations.BuildOperationRunnerprotected FileSystemOperationsAllows filtering tests for execution.protected org.gradle.internal.nativeintegration.network.HostnameLookupbooleanSpecifies whether the build should break when the verifications performed by this task fail.protected org.gradle.internal.reflect.Instantiatorprotected org.gradle.internal.event.ListenerManagerReturns the reasons for no matching test error.protected org.gradle.internal.logging.progress.ProgressLoggerFactoryThe reports that this task potentially produces.Allows to set options related to which test events are logged to the console, and on which detail level.protected org.gradle.internal.logging.text.StyledTextOutputFactoryvoidAdds a closure to be notified when output from the test received.voidremoveTestListener(TestListener listener) Unregisters a test listener with this task.voidremoveTestOutputListener(TestOutputListener listener) Unregisters a test output listener with this task.Configures the reports that this task potentially produces.reports(Action<? super TestTaskReports> configureAction) Configures the reports that this task potentially produces.voidsetIgnoreFailures(boolean ignoreFailures) Specifies whether the build should break when the verifications performed by this task fail.setTestNameIncludePatterns(List<String> testNamePattern) Sets the test name patterns to be included in execution.voidtestLogging(Closure closure) Allows configuring the logging of the test execution, for example log eagerly the standard output, etc.voidtestLogging(Action<? super TestLoggingContainer> action) Allows configuring the logging of the test execution, for example log eagerly the standard output, etc.Methods inherited from class org.gradle.api.internal.ConventionTaskconventionMapping, conventionMapping, getConventionMappingMethods inherited from class org.gradle.api.DefaultTaskcompareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesServiceMethods inherited from class org.gradle.api.internal.AbstractTaskacceptServiceReferences, appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjectsMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gradle.api.TaskdoNotTrackState, getConvention, notCompatibleWithConfigurationCache
- 
Constructor Details- 
AbstractTestTaskpublic AbstractTestTask()
 
- 
- 
Method Details- 
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()
- 
getFileSystemOperations
- 
createTestExecuterprotected 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
 
- 
createTestExecutionSpecprotected abstract org.gradle.api.internal.tasks.testing.TestExecutionSpec createTestExecutionSpec()Creates test execution specification. For internal use only.- Since:
- 4.4
 
- 
getBinaryResultsDirectoryReturns the root directory property for the test results in internal binary format.- Since:
- 4.4
 
- 
addTestListenerRegisters a test listener with this task. Consider also the following handy methods for quicker hooking into test execution:beforeTest(groovy.lang.Closure),afterTest(groovy.lang.Closure),beforeSuite(groovy.lang.Closure),afterSuite(groovy.lang.Closure)This listener will NOT be notified of tests executed by other tasks. To get that behavior, use Gradle.addListener(Object).- Parameters:
- listener- The listener to add.
 
- 
addTestOutputListenerRegisters a output listener with this task. Quicker way of hooking into output events is using theonOutput(groovy.lang.Closure)method.- Parameters:
- listener- The listener to add.
 
- 
removeTestListenerUnregisters a test listener with this task. This method will only remove listeners that were added by callingaddTestListener(TestListener)on this task. If the listener was registered with Gradle usingGradle.addListener(Object)this method will not do anything. Instead, useGradle.removeListener(Object).- Parameters:
- listener- The listener to remove.
 
- 
removeTestOutputListenerUnregisters a test output listener with this task. This method will only remove listeners that were added by callingaddTestOutputListener(TestOutputListener)on this task. If the listener was registered with Gradle usingGradle.addListener(Object)this method will not do anything. Instead, useGradle.removeListener(Object).- Parameters:
- listener- The listener to remove.
 
- 
getIgnoreFailuresSpecifies whether the build should break when the verifications performed by this task fail.- Specified by:
- getIgnoreFailuresin interface- VerificationTask
- Returns:
- false, when the build should break on failure, true when the failures should be ignored.
 
- 
setIgnoreFailurespublic void setIgnoreFailures(boolean ignoreFailures) Specifies whether the build should break when the verifications performed by this task fail.- Specified by:
- setIgnoreFailuresin interface- VerificationTask
- Parameters:
- ignoreFailures- false to break the build on failure, true to ignore the failures. The default is false.
 
- 
onOutputAdds a closure to be notified when output from the test received. ATestDescriptorandTestOutputEventinstance 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.
 
- 
beforeSuiteAdds a closure to be notified before a test suite is executed. A TestDescriptorinstance 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.
 
- 
afterSuiteAdds a closure to be notified after a test suite has executed. A TestDescriptorandTestResultinstance 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.
 
- 
beforeTestAdds a closure to be notified before a test is executed. ATestDescriptorinstance is passed to the closure as a parameter.- Parameters:
- closure- The closure to call.
 
- 
afterTestAdds a closure to be notified after a test has executed. ATestDescriptorandTestResultinstance are passed to the closure as a parameter.- Parameters:
- closure- The closure to call.
 
- 
getTestLoggingAllows 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 seeTestLoggingContainer.- Returns:
- this
 
- 
testLoggingAllows 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
 
- 
testLoggingAllows 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
 
- 
executeTestspublic void executeTests()
- 
getNoMatchingTestErrorReasonsReturns the reasons for no matching test error.- Since:
- 4.5
 
- 
setTestNameIncludePatternsSets 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 seeTestFilter
- 
getReportsThe reports that this task potentially produces.- Specified by:
- getReportsin interface- Reporting<TestTaskReports>
- Returns:
- The reports that this task potentially produces
 
- 
reportsConfigures the reports that this task potentially produces.- Specified by:
- reportsin interface- Reporting<TestTaskReports>
- Parameters:
- closure- The configuration
- Returns:
- The reports that this task potentially produces
 
- 
reportsConfigures the reports that this task potentially produces.- Specified by:
- reportsin interface- Reporting<TestTaskReports>
- Parameters:
- configureAction- The configuration
- Returns:
- The reports that this task potentially produces
 
- 
getFilterAllows filtering tests for execution.- Returns:
- filter object
- Since:
- 1.10
 
 
-