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>
Note: This abstract class is not intended for implementation by build script or plugin authors.
Task.Namer
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
Constructor | Description |
---|---|
AbstractTestTask() |
Modifier and Type | Method | Description |
---|---|---|
void |
addTestListener(TestListener listener) |
Registers a test listener with this task.
|
void |
addTestOutputListener(TestOutputListener listener) |
Registers a output listener with this task.
|
void |
afterSuite(Closure closure) |
Adds a closure to be notified after a test suite has executed.
|
void |
afterTest(Closure closure) |
Adds a closure to be notified after a test has executed.
|
void |
beforeSuite(Closure closure) |
Adds a closure to be notified before a test suite is executed.
|
void |
beforeTest(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> |
createTestExecuter() |
Creates test executer.
|
protected abstract org.gradle.api.internal.tasks.testing.TestExecutionSpec |
createTestExecutionSpec() |
Creates test execution specification.
|
void |
executeTests() |
|
DirectoryProperty |
getBinaryResultsDirectory() |
Returns the root directory property for the test results in internal binary format.
|
File |
getBinResultsDir() |
Returns the root folder for the test results in internal binary format.
|
protected org.gradle.internal.operations.BuildOperationExecutor |
getBuildOperationExecutor() |
|
boolean |
getIgnoreFailures() |
Specifies whether the build should break when the verifications performed by this task fail.
|
protected org.gradle.internal.remote.internal.inet.InetAddressFactory |
getInetAddressFactory() |
|
protected org.gradle.internal.reflect.Instantiator |
getInstantiator() |
|
protected org.gradle.internal.event.ListenerManager |
getListenerManager() |
|
protected org.gradle.internal.logging.progress.ProgressLoggerFactory |
getProgressLoggerFactory() |
|
TestTaskReports |
getReports() |
The reports that this task potentially produces.
|
TestLoggingContainer |
getTestLogging() |
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.StyledTextOutputFactory |
getTextOutputFactory() |
|
void |
onOutput(Closure closure) |
Adds a closure to be notified when output from the test received.
|
void |
removeTestListener(TestListener listener) |
Unregisters a test listener with this task.
|
void |
removeTestOutputListener(TestOutputListener listener) |
Unregisters a test output listener with this task.
|
TestTaskReports |
reports(Closure closure) |
Configures the reports that this task potentially produces.
|
TestTaskReports |
reports(Action<? super TestTaskReports> configureAction) |
Configures the reports that this task potentially produces.
|
void |
setBinResultsDir(File binResultsDir) |
Sets the root folder for the test results in internal binary format.
|
void |
setIgnoreFailures(boolean ignoreFailures) |
Specifies whether the build should break when the verifications performed by this task fail.
|
void |
testLogging(Closure closure) |
Allows configuring the logging of the test execution, for example log eagerly the standard output, etc.
|
void |
testLogging(Action<? super TestLoggingContainer> action) |
Allows configuring the logging of the test execution, for example log eagerly the standard output, etc.
|
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
conventionMapping, conventionMapping, getConventionMapping
newInputDirectory, newInputFile, newOutputDirectory, newOutputFile
@Inject protected org.gradle.internal.logging.progress.ProgressLoggerFactory getProgressLoggerFactory()
@Inject protected org.gradle.internal.logging.text.StyledTextOutputFactory getTextOutputFactory()
@Inject protected org.gradle.internal.remote.internal.inet.InetAddressFactory getInetAddressFactory()
@Inject protected org.gradle.internal.operations.BuildOperationExecutor getBuildOperationExecutor()
@Inject protected org.gradle.internal.reflect.Instantiator getInstantiator()
@Inject protected org.gradle.internal.event.ListenerManager getListenerManager()
@Incubating protected abstract org.gradle.api.internal.tasks.testing.TestExecuter<? extends org.gradle.api.internal.tasks.testing.TestExecutionSpec> createTestExecuter()
@Incubating protected abstract org.gradle.api.internal.tasks.testing.TestExecutionSpec createTestExecutionSpec()
@OutputDirectory @Incubating public File getBinResultsDir()
@Incubating public void setBinResultsDir(File binResultsDir)
binResultsDir
- The root folder@Internal @Incubating public DirectoryProperty getBinaryResultsDirectory()
public void addTestListener(TestListener listener)
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)
.
listener
- The listener to add.public void addTestOutputListener(TestOutputListener listener)
onOutput(groovy.lang.Closure)
method.listener
- The listener to add.public void removeTestListener(TestListener listener)
addTestListener(TestListener)
on this task. If the listener was
registered with Gradle using Gradle.addListener(Object)
this method will not do anything. Instead, use Gradle.removeListener(Object)
.listener
- The listener to remove.public void removeTestOutputListener(TestOutputListener listener)
addTestOutputListener(TestOutputListener)
on this task. If the
listener was registered with Gradle using Gradle.addListener(Object)
this method will not do anything. Instead, use Gradle.removeListener(Object)
.listener
- The listener to remove.@Internal public boolean getIgnoreFailures()
getIgnoreFailures
in interface VerificationTask
public void setIgnoreFailures(boolean ignoreFailures)
setIgnoreFailures
in interface VerificationTask
ignoreFailures
- false to break the build on failure, true to ignore the failures. The default is false.public void onOutput(Closure closure)
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) } } }
closure
- The closure to call.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.
closure
- The closure to call.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.
closure
- The closure to call.public void beforeTest(Closure closure)
TestDescriptor
instance is passed to the closure as a parameter.closure
- The closure to call.public void afterTest(Closure closure)
TestDescriptor
and TestResult
instance are passed to the closure as a parameter.closure
- The closure to call.@Internal public TestLoggingContainer getTestLogging()
apply plugin: 'java' test.testLogging { exceptionFormat "full" }For further information see
TestLoggingContainer
.public void testLogging(Closure closure)
apply plugin: 'java' // makes the standard streams (err and out) visible at console when running tests test.testLogging { showStandardStreams = true }
closure
- configure closurepublic void testLogging(Action<? super TestLoggingContainer> action)
apply plugin: 'java' // makes the standard streams (err and out) visible at console when running tests test.testLogging { showStandardStreams = true }
action
- configure actionpublic void executeTests()
public TestTaskReports getReports()
getReports
in interface Reporting<TestTaskReports>
public TestTaskReports reports(Closure closure)
reports
in interface Reporting<TestTaskReports>
closure
- The configurationpublic TestTaskReports reports(Action<? super TestTaskReports> configureAction)
reports
in interface Reporting<TestTaskReports>
configureAction
- The configuration