|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.gradle.api.internal.AbstractTask org.gradle.api.DefaultTask org.gradle.api.internal.ConventionTask org.gradle.api.tasks.testing.Test
public class Test
Executes tests. Supports JUnit (3.8.x or 4.x) or TestNG tests.
Field Summary |
---|
Fields inherited from interface org.gradle.api.Task |
---|
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_NAME, TASK_OVERWRITE, TASK_TYPE |
Constructor Summary | |
---|---|
Test()
|
Method Summary | |
---|---|
void |
addTestListener(TestListener listener)
Registers a test 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. |
Test |
bootstrapClasspath(Object... classpath)
Adds the given values to the end of the bootstrap classpath for the process. |
Test |
copyTo(JavaForkOptions target)
Copies these options to the given options. |
Test |
copyTo(ProcessForkOptions target)
Copies these options to the given target options. |
void |
disableTestReport()
|
void |
enableTestReport()
|
Test |
environment(Map<String,?> environmentVariables)
Adds some environment variables to the environment for this process. |
Test |
environment(String name,
Object value)
Adds an environment variable to the environment for this process. |
Test |
exclude(Closure excludeSpec)
Adds an exclude spec. |
Test |
exclude(Iterable<String> excludes)
Adds exclude patterns for the files in the test classes directory (e.g. |
Test |
exclude(Spec<FileTreeElement> excludeSpec)
Adds an exclude spec. |
Test |
exclude(String... excludes)
Adds exclude patterns for the files in the test classes directory (e.g. |
Test |
executable(Object executable)
Sets the name of the executable to use. |
void |
executeTests()
|
List<String> |
getAllJvmArgs()
Returns the full set of arguments to use to launch the JVM for the process. |
FileCollection |
getBootstrapClasspath()
Returns the bootstrap classpath to use for the process. |
FileTree |
getCandidateClassFiles()
Returns the classes files to scan for test classes. |
FileCollection |
getClasspath()
|
boolean |
getDebug()
Returns true if debugging is enabled for the process. |
boolean |
getEnableAssertions()
Returns true if assertions are enabled for the process. |
Map<String,Object> |
getEnvironment()
The environment variables to use for the process. |
Set<String> |
getExcludes()
Returns the exclude patterns for test execution. |
String |
getExecutable()
Returns the name of the executable to use. |
long |
getForkEvery()
Returns the maximum number of test classes to execute in a forked test process. |
Set<String> |
getIncludes()
Returns the include patterns for test execution. |
List<String> |
getJvmArgs()
Returns the extra arguments to use to launch the JVM for the process. |
String |
getMaxHeapSize()
Returns the maximum heap size for the process, if any. |
int |
getMaxParallelForks()
Returns the maximum number of forked test processes to execute in parallel. |
TestFrameworkOptions |
getOptions()
Returns the test options options. |
Map<String,Object> |
getSystemProperties()
Returns the system properties which will be used for the process. |
File |
getTestClassesDir()
Returns the root folder for the compiled test sources. |
org.gradle.api.internal.tasks.testing.TestFramework |
getTestFramework()
|
File |
getTestReportDir()
Returns the root folder for the test reports. |
File |
getTestResultsDir()
Returns the root folder for the test results. |
List<File> |
getTestSrcDirs()
|
File |
getWorkingDir()
Returns the working directory for the process. |
Test |
include(Closure includeSpec)
Adds an include spec. |
Test |
include(Iterable<String> includes)
Adds include patterns for the files in the test classes directory (e.g. |
Test |
include(Spec<FileTreeElement> includeSpec)
Adds an include spec. |
Test |
include(String... includes)
Adds include patterns for the files in the test classes directory (e.g. |
boolean |
isIgnoreFailures()
Returns whether the build should break when the verifications performed by this task fail. |
boolean |
isScanForTestClasses()
|
boolean |
isTestReport()
|
Test |
jvmArgs(Iterable<?> arguments)
Adds some arguments to use to launch the JVM for the process. |
Test |
jvmArgs(Object... arguments)
Adds some arguments to use to launch the JVM for the process. |
TestFrameworkOptions |
options(Closure testFrameworkConfigure)
|
void |
removeTestListener(TestListener listener)
Unregisters a test listener with this task. |
void |
setAllJvmArgs(Iterable<?> arguments)
Sets the full set of arguments to use to launch the JVM for the process. |
void |
setBootstrapClasspath(FileCollection classpath)
Sets the bootstrap classpath to use for the process. |
void |
setClasspath(FileCollection classpath)
|
void |
setDebug(boolean enabled)
Enable or disable debugging for the process. |
void |
setEnableAssertions(boolean enabled)
Enable or disable assertions for the process. |
void |
setEnvironment(Map<String,?> environmentVariables)
Sets the environment variable to use for the process. |
Test |
setExcludes(Iterable<String> excludes)
Sets the exclude patterns for test execution. |
void |
setExecutable(Object executable)
Sets the name of the executable to use. |
void |
setForkEvery(Long forkEvery)
Sets the maximum number of test classes to execute in a forked test process. |
Test |
setIgnoreFailures(boolean ignoreFailures)
Specify whether the build should break when the verifications performed by this task fail. |
Test |
setIncludes(Iterable<String> includes)
Sets the include patterns for test execution. |
void |
setJvmArgs(Iterable<?> arguments)
Sets the extra arguments to use to launch the JVM for the process. |
void |
setMaxHeapSize(String heapSize)
Sets the maximum heap size for the process. |
void |
setMaxParallelForks(int maxParallelForks)
Sets the maximum number of forked test processes to execute in parallel. |
void |
setScanForTestClasses(boolean scanForTestClasses)
|
void |
setSystemProperties(Map<String,?> properties)
Sets the system properties to use for the process. |
void |
setTestClassesDir(File testClassesDir)
Sets the root folder for the compiled test sources. |
void |
setTestReport(boolean testReport)
|
void |
setTestReportDir(File testReportDir)
Sets the root folder for the test reports. |
void |
setTestResultsDir(File testResultsDir)
Sets the root folder for the test results. |
void |
setTestSrcDirs(List<File> testSrcDir)
|
void |
setWorkingDir(Object dir)
Sets the working directory for the process. |
Test |
systemProperties(Map<String,?> properties)
Adds some system properties to use for the process. |
Test |
systemProperty(String name,
Object value)
Adds a system property to use for the process. |
org.gradle.api.internal.tasks.testing.TestFramework |
testFramework(Closure testFrameworkConfigure)
|
org.gradle.api.internal.tasks.testing.TestFramework |
useJUnit()
Specifies that JUnit should be used to execute the tests. |
org.gradle.api.internal.tasks.testing.TestFramework |
useJUnit(Closure testFrameworkConfigure)
Specifies that JUnit should be used to execute the tests. |
org.gradle.api.internal.tasks.testing.TestFramework |
useTestNG()
Specifies that TestNG should be used to execute the tests. |
org.gradle.api.internal.tasks.testing.TestFramework |
useTestNG(Closure testFrameworkConfigure)
Specifies that TestNG should be used to execute the tests. |
Test |
workingDir(Object dir)
Sets the working directory for the process. |
Methods inherited from class org.gradle.api.internal.ConventionTask |
---|
conventionMapping, getConventionMapping, setConventionMapping |
Methods inherited from class org.gradle.api.internal.AbstractTask |
---|
captureStandardOutput, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, disableStandardOutputCapture, doFirst, doFirst, doLast, doLast, equals, execute, getActions, getAdditionalProperties, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getDynamicObjectHelper, getEnabled, getExecuter, getGroup, getInputs, getLogger, getLogging, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getStandardOutputCapture, getState, getTaskDependencies, getTemporaryDir, hashCode, hasProperty, injectIntoNewInstance, isEnabled, leftShift, onlyIf, onlyIf, property, setActions, setConvention, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setGroup, setName, setOnlyIf, setOnlyIf, setProject, setProperty, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Test()
Method Detail |
---|
public File getWorkingDir()
getWorkingDir
in interface ProcessForkOptions
public void setWorkingDir(Object dir)
Project.file(Object)
.
setWorkingDir
in interface ProcessForkOptions
dir
- The working directory. Must not be null.public Test workingDir(Object dir)
Project.file(Object)
.
workingDir
in interface ProcessForkOptions
dir
- The working directory. Must not be null.
public String getExecutable()
getExecutable
in interface ProcessForkOptions
public Test executable(Object executable)
executable
in interface ProcessForkOptions
executable
- The executable. Must not be null.
public void setExecutable(Object executable)
setExecutable
in interface ProcessForkOptions
executable
- The executable. Must not be null.public Map<String,Object> getSystemProperties()
getSystemProperties
in interface JavaForkOptions
public void setSystemProperties(Map<String,?> properties)
setSystemProperties
in interface JavaForkOptions
properties
- The system properties. Must not be null.public Test systemProperties(Map<String,?> properties)
systemProperties
in interface JavaForkOptions
properties
- The system properties. Must not be null.
public Test systemProperty(String name, Object value)
systemProperty
in interface JavaForkOptions
name
- The name of the propertyvalue
- The value for the property. May be null.
public FileCollection getBootstrapClasspath()
getBootstrapClasspath
in interface JavaForkOptions
public void setBootstrapClasspath(FileCollection classpath)
setBootstrapClasspath
in interface JavaForkOptions
classpath
- The classpath. Must not be null. Can be empty.public Test bootstrapClasspath(Object... classpath)
bootstrapClasspath
in interface JavaForkOptions
classpath
- The classpath.
public String getMaxHeapSize()
getMaxHeapSize
in interface JavaForkOptions
public void setMaxHeapSize(String heapSize)
setMaxHeapSize
in interface JavaForkOptions
heapSize
- The heap size. Use null for the default maximum heap size.public List<String> getJvmArgs()
getJvmArgs
in interface JavaForkOptions
public void setJvmArgs(Iterable<?> arguments)
setJvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.public Test jvmArgs(Iterable<?> arguments)
jvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.
public Test jvmArgs(Object... arguments)
jvmArgs
in interface JavaForkOptions
arguments
- The arguments.
public boolean getEnableAssertions()
getEnableAssertions
in interface JavaForkOptions
public void setEnableAssertions(boolean enabled)
setEnableAssertions
in interface JavaForkOptions
enabled
- true to enable assertions, false to disable.public boolean getDebug()
getDebug
in interface JavaForkOptions
public void setDebug(boolean enabled)
setDebug
in interface JavaForkOptions
enabled
- true to enable debugging, false to disable.public List<String> getAllJvmArgs()
getAllJvmArgs
in interface JavaForkOptions
public void setAllJvmArgs(Iterable<?> arguments)
setAllJvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.public Map<String,Object> getEnvironment()
getEnvironment
in interface ProcessForkOptions
public Test environment(Map<String,?> environmentVariables)
environment
in interface ProcessForkOptions
environmentVariables
- The environment variables. Must not be null.
public Test environment(String name, Object value)
environment
in interface ProcessForkOptions
name
- The name of the variable.value
- The value for the variable. Must not be null.
public void setEnvironment(Map<String,?> environmentVariables)
setEnvironment
in interface ProcessForkOptions
environmentVariables
- The environment variables. Must not be null.public Test copyTo(ProcessForkOptions target)
copyTo
in interface ProcessForkOptions
target
- The target options
public Test copyTo(JavaForkOptions target)
copyTo
in interface JavaForkOptions
target
- The target options.
public void executeTests()
public void addTestListener(TestListener listener)
Gradle.addListener(Object)
.
listener
- The listener to add.public void removeTestListener(TestListener listener)
addTestListener(org.gradle.api.tasks.testing.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 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.public Test include(String... includes)
include
in interface PatternFilterable
includes
- a vararg list of include patterns
setIncludes(Iterable)
public Test include(Iterable<String> includes)
include
in interface PatternFilterable
includes
- a Iterable providing more include patterns
setIncludes(Iterable)
public Test include(Spec<FileTreeElement> includeSpec)
PatternFilterable
include
in interface PatternFilterable
includeSpec
- the spec to add
Pattern Format
public Test include(Closure includeSpec)
PatternFilterable
FileTreeElement
as its parameter.
If includes are not provided, then all files in this container will be included. If includes are provided, then a
file must match at least one of the include patterns or specs to be included.
include
in interface PatternFilterable
includeSpec
- the spec to add
Pattern Format
public Test exclude(String... excludes)
exclude
in interface PatternFilterable
excludes
- a vararg list of exclude patterns
setExcludes(Iterable)
public Test exclude(Iterable<String> excludes)
exclude
in interface PatternFilterable
excludes
- a Iterable providing new exclude patterns
setExcludes(Iterable)
public Test exclude(Spec<FileTreeElement> excludeSpec)
PatternFilterable
exclude
in interface PatternFilterable
excludeSpec
- the spec to add
Pattern Format
public Test exclude(Closure excludeSpec)
PatternFilterable
FileTreeElement
as its parameter.
If excludes are not provided, then no files will be excluded. If excludes are provided, then files must not match
any exclude pattern to be processed.
exclude
in interface PatternFilterable
excludeSpec
- the spec to add
Pattern Format
public File getTestClassesDir()
public void setTestClassesDir(File testClassesDir)
testClassesDir
- The root folderpublic File getTestResultsDir()
public void setTestResultsDir(File testResultsDir)
testResultsDir
- The root folderpublic File getTestReportDir()
public void setTestReportDir(File testReportDir)
testReportDir
- The root folderpublic Set<String> getIncludes()
getIncludes
in interface PatternFilterable
include(String...)
public Test setIncludes(Iterable<String> includes)
setIncludes
in interface PatternFilterable
includes
- The patterns list
include(String...)
public Set<String> getExcludes()
getExcludes
in interface PatternFilterable
exclude(String...)
public Test setExcludes(Iterable<String> excludes)
setExcludes
in interface PatternFilterable
excludes
- The patterns list
exclude(String...)
public boolean isIgnoreFailures()
isIgnoreFailures
in interface VerificationTask
public Test 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 org.gradle.api.internal.tasks.testing.TestFramework getTestFramework()
public org.gradle.api.internal.tasks.testing.TestFramework testFramework(Closure testFrameworkConfigure)
public TestFrameworkOptions getOptions()
Returns the test options options.
Be sure to call the appropriate useJUnit()
or useTestNG()
method before using this method.
public TestFrameworkOptions options(Closure testFrameworkConfigure)
public org.gradle.api.internal.tasks.testing.TestFramework useJUnit()
public org.gradle.api.internal.tasks.testing.TestFramework useJUnit(Closure testFrameworkConfigure)
testFrameworkConfigure
- A closure used to configure the JUint options. This closure is passed an instance
of type JUnitOptions
.public org.gradle.api.internal.tasks.testing.TestFramework useTestNG()
public org.gradle.api.internal.tasks.testing.TestFramework useTestNG(Closure testFrameworkConfigure)
testFrameworkConfigure
- A closure used to configure the JUint options. This closure is passed an instance
of type JUnitOptions
.public FileCollection getClasspath()
public void setClasspath(FileCollection classpath)
public boolean isTestReport()
public void setTestReport(boolean testReport)
public void enableTestReport()
public void disableTestReport()
public List<File> getTestSrcDirs()
public void setTestSrcDirs(List<File> testSrcDir)
public boolean isScanForTestClasses()
public void setScanForTestClasses(boolean scanForTestClasses)
public long getForkEvery()
public void setForkEvery(Long forkEvery)
forkEvery
- The maximum number of test classes. Use null or 0 to specify no maximum.public int getMaxParallelForks()
public void setMaxParallelForks(int maxParallelForks)
maxParallelForks
- The maximum number of forked test processes.public FileTree getCandidateClassFiles()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |