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, ExtensionAware, Reporting<TestTaskReports>, Task, VerificationTask, org.gradle.util.Configurable<Task>
public abstract class AbstractTestTask
extends org.gradle.api.internal.ConventionTask
implements VerificationTask, Reporting<TestTaskReports>
Abstract class for all test task.
- 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 Summary
Nested classes/interfaces inherited from interface Task
Task.Namer -
Field Summary
Fields inherited from interface Task
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier 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.Returns the root folder for the test results in internal binary format.protected org.gradle.internal.operations.BuildOperationExecutorbooleanSpecifies whether the build should break when the verifications performed by this task fail.protected org.gradle.internal.remote.internal.inet.InetAddressFactoryprotected org.gradle.internal.reflect.Instantiatorprotected org.gradle.internal.event.ListenerManagerprotected 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.voidsetBinResultsDir(File binResultsDir) Sets the root folder for the test results in internal binary format.voidsetIgnoreFailures(boolean ignoreFailures) Specifies whether the build should break when the verifications performed by this task fail.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.ConventionTask
conventionMapping, conventionMapping, getConventionMappingMethods inherited from class DefaultTask
newInputDirectory, newInputFile, newOutputDirectory, newOutputFileMethods inherited from class org.gradle.api.internal.AbstractTask
addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doFirst, doLast, doLast, doLast, execute, finalizedBy, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString
-
Constructor Details
-
AbstractTestTask
public AbstractTestTask()
-
-
Method Details
-
getProgressLoggerFactory
@Inject protected org.gradle.internal.logging.progress.ProgressLoggerFactory getProgressLoggerFactory() -
getTextOutputFactory
@Inject protected org.gradle.internal.logging.text.StyledTextOutputFactory getTextOutputFactory() -
getInetAddressFactory
@Inject protected org.gradle.internal.remote.internal.inet.InetAddressFactory getInetAddressFactory() -
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
@Incubating 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
@Incubating protected abstract org.gradle.api.internal.tasks.testing.TestExecutionSpec createTestExecutionSpec()Creates test execution specification. For internal use only.- Since:
- 4.4
-
getBinResultsDir
Returns the root folder for the test results in internal binary format.- Returns:
- the test result directory, containing the test results in binary format.
-
setBinResultsDir
Sets the root folder for the test results in internal binary format.- Parameters:
binResultsDir- The root folder
-
getBinaryResultsDirectory
Returns the root directory property for the test results in internal binary format.- Since:
- 4.4
-
addTestListener
Registers 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.
-
addTestOutputListener
Registers 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.
-
removeTestListener
Unregisters 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.
-
removeTestOutputListener
Unregisters 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.
-
getIgnoreFailures
Specifies whether the build should break when the verifications performed by this task fail.- Specified by:
getIgnoreFailuresin interfaceVerificationTask- 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:
setIgnoreFailuresin interfaceVerificationTask- Parameters:
ignoreFailures- false to break the build on failure, true to ignore the failures. The default is false.
-
onOutput
Adds 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.
-
beforeSuite
Adds 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.
-
afterSuite
Adds 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.
-
beforeTest
Adds 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.
-
afterTest
Adds 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.
-
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 seeTestLoggingContainer.- Returns:
- this
-
testLogging
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
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() -
getReports
The reports that this task potentially produces.- Specified by:
getReportsin interfaceReporting<TestTaskReports>- Returns:
- The reports that this task potentially produces
-
reports
Configures the reports that this task potentially produces.- Specified by:
reportsin interfaceReporting<TestTaskReports>- Parameters:
closure- The configuration- Returns:
- The reports that this task potentially produces
-
reports
Configures the reports that this task potentially produces.- Specified by:
reportsin interfaceReporting<TestTaskReports>- Parameters:
configureAction- The configuration- Returns:
- The reports that this task potentially produces
-