API Documentation: | AbstractTestTask |
---|
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.
Property | Description |
binResultsDir | Deprecated Replaced The root folder for the test results in internal binary format. |
binaryResultsDirectory | The root directory property for the test results in internal binary format. |
ignoreFailures | Specifies whether the build should break when the verifications performed by this task fail. |
reports | The reports that this task potentially produces. |
Method | Description |
addTestListener(listener) | Registers a test listener with this task. Consider also the following handy methods for quicker hooking into test execution: |
addTestOutputListener(listener) | Registers a output listener with this task. Quicker way of hooking into output events is using the |
afterSuite(closure) | Adds a closure to be notified after a test suite has executed. A |
afterTest(closure) | Adds a closure to be notified after a test has executed. A |
beforeSuite(closure) | Adds a closure to be notified before a test suite is executed. A |
beforeTest(closure) | Adds a closure to be notified before a test is executed. A |
onOutput(closure) | Adds a closure to be notified when output from the test received. A |
removeTestListener(listener) | Unregisters a test listener with this task. This method will only remove listeners that were added by calling |
removeTestOutputListener(listener) | Unregisters a test output listener with this task. This method will only remove listeners that were added by calling |
reports(configureAction) | Configures the reports that this task potentially produces. |
setTestNameIncludePatterns(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 |
Block | Description |
reports | Configures the reports that this task potentially produces. |
File
binResultsDir
Note: This property is deprecated and will be removed in the next major version of Gradle.
Note: This property has been replaced by binaryResultsDirectory.
The root folder for the test results in internal binary format.
- Default:
project.testResultsDir
/binary/task.name
DirectoryProperty
binaryResultsDirectory
The root directory property for the test results in internal binary format.
Specifies whether the build should break when the verifications performed by this task fail.
TestTaskReports
reports
(read-only)
The reports that this task potentially produces.
void
addTestListener
(TestListener
listener)
Registers a test listener with this task. Consider also the following handy methods for quicker hooking into test execution: AbstractTestTask.beforeTest(groovy.lang.Closure)
, AbstractTestTask.afterTest(groovy.lang.Closure)
, AbstractTestTask.beforeSuite(groovy.lang.Closure)
, AbstractTestTask.afterSuite(groovy.lang.Closure)
This listener will NOT be notified of tests executed by other tasks. To
get that behavior, use Gradle.addListener(java.lang.Object)
.
void
addTestOutputListener
(TestOutputListener
listener)
Registers a output listener with this task. Quicker way of hooking into output events is using the AbstractTestTask.onOutput(groovy.lang.Closure)
method.
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.
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.
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.
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.
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) } } }
void
removeTestListener
(TestListener
listener)
Unregisters a test listener with this task. This method will only remove listeners that were added by calling AbstractTestTask.addTestListener(org.gradle.api.tasks.testing.TestListener)
on this task. If the listener was
registered with Gradle using Gradle.addListener(java.lang.Object)
this method will not do anything. Instead, use Gradle.removeListener(java.lang.Object)
.
void
removeTestOutputListener
(TestOutputListener
listener)
Unregisters a test output listener with this task. This method will only remove listeners that were added by calling AbstractTestTask.addTestOutputListener(org.gradle.api.tasks.testing.TestOutputListener)
on this task. If the
listener was registered with Gradle using Gradle.addListener(java.lang.Object)
this method will not do anything. Instead, use Gradle.removeListener(java.lang.Object)
.
TestTaskReports
reports
(Action
<? super TestTaskReports
>
configureAction)
Action
<? super TestTaskReports
>Configures the reports that this task potentially produces.
AbstractTestTask
setTestNameIncludePatterns
(List
<String
>
testNamePattern)
List
<String
>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
Configures the reports that this task potentially produces.
- Delegates to:
TestTaskReports
fromreports