Package org.gradle.api.tasks.testing
Class Test
java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.testing.AbstractTestTask
org.gradle.api.tasks.testing.Test
- All Implemented Interfaces:
Comparable<Task>
,org.gradle.api.internal.DynamicObjectAware
,org.gradle.api.internal.IConventionAware
,org.gradle.api.internal.TaskInternal
,ExtensionAware
,Reporting<TestTaskReports>
,Task
,PatternFilterable
,VerificationTask
,JavaForkOptions
,ProcessForkOptions
,org.gradle.util.Configurable<Task>
@CacheableTask
public class Test
extends AbstractTestTask
implements JavaForkOptions, PatternFilterable
Executes JUnit (3.8.x or 4.x) or TestNG tests. Test are always run in (one or more) separate JVMs.
The sample below shows various configuration options.
apply plugin: 'java' // adds 'test' task test { // enable TestNG support (default is JUnit) useTestNG() // set a system property for the test JVM(s) systemProperty 'some.prop', 'value' // explicitly include or exclude tests include 'org/foo/**' exclude 'org/boo/**' // show standard out and standard error of the test JVM(s) on the console testLogging.showStandardStreams = true // set heap size for the test JVM(s) minHeapSize = "128m" maxHeapSize = "512m" // set JVM arguments for the test JVM(s) jvmArgs '-XX:MaxPermSize=256m' // listen to events in the test execution lifecycle beforeTest { descriptor -> logger.lifecycle("Running test: " + descriptor) } // listen to standard out and standard error of the test JVM(s) onOutput { descriptor, event -> logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) } }
The test process can be started in debug mode (see getDebug()
) in an ad-hoc manner by supplying the `--debug-jvm` switch when invoking the build.
gradle someTestTask --debug-jvm
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.gradle.api.Task
Task.Namer
-
Field Summary
Fields inherited from interface org.gradle.api.Task
TASK_ACTION, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbootstrapClasspath
(Object... classpath) Adds the given values to the end of the bootstrap classpath for the process.copyTo
(JavaForkOptions target) Copies these options to the given options.copyTo
(ProcessForkOptions target) Copies these options to the given target options.protected org.gradle.api.internal.tasks.testing.TestExecuter<org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec>
Creates test executer.protected org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec
Creates test execution specification.environment
(String name, Object value) Adds an environment variable to the environment for this process.environment
(Map<String, ?> environmentVariables) Adds some environment variables to the environment for this process.Adds an exclude spec.Adds exclude patterns for the files in the test classes directory (e.g.Adds exclude patterns for the files in the test classes directory (e.g.exclude
(Spec<FileTreeElement> excludeSpec) Adds an exclude spec.executable
(Object executable) Sets the name of the executable to use.void
void
filter
(Action<TestFilter> action) Executes the action against thegetFilter()
.protected org.gradle.internal.actor.ActorFactory
Returns the full set of arguments to use to launch the JVM for the process.Returns the bootstrap classpath to use for the process.Returns the classes files to scan for test classes.protected org.gradle.api.internal.initialization.loadercache.ClassLoaderCache
Returns the classpath to use to execute the tests.boolean
getDebug()
Returns true if debugging is enabled for the process.Returns the default character encoding to use.boolean
Returns true if assertions are enabled for the process.The environment variables to use for the process.Returns the exclude patterns for test execution.Returns the name of the executable to use.protected org.gradle.api.internal.file.FileResolver
Allows filtering tests for execution.long
Returns the maximum number of test classes to execute in a forked test process.Returns the include patterns for test execution.Returns the version of Java used to run the tests based on the executable specified bygetExecutable()
.Returns the extra arguments to use to launch the JVM for the process.Returns the maximum heap size for the process, if any.int
Returns the maximum number of forked test processes to execute in parallel.Returns the minimum heap size for the process, if any.protected org.gradle.api.internal.classpath.ModuleRegistry
Returns test framework specific options.protected org.gradle.process.internal.worker.WorkerProcessFactory
Returns the system properties which will be used for the process.Deprecated.Returns the directories for the compiled test sources.org.gradle.api.internal.tasks.testing.TestFramework
Returns the working directory for the process.Adds an include spec.Adds include patterns for the files in the test classes directory (e.g.Adds include patterns for the files in the test classes directory (e.g.include
(Spec<FileTreeElement> includeSpec) Adds an include spec.boolean
Specifies whether test classes should be detected.Adds some arguments to use to launch the JVM for the process.Adds some arguments to use to launch the JVM for the process.Configures test framework specific options.options
(Action<? super TestFrameworkOptions> testFrameworkConfigure) Configures test framework specific options.void
setAllJvmArgs
(Iterable<?> arguments) Sets the full set of arguments to use to launch the JVM for the process.void
setAllJvmArgs
(List<String> 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
setDefaultCharacterEncoding
(String defaultCharacterEncoding) Sets the default character encoding to use.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.setExcludes
(Iterable<String> excludes) Sets the exclude patterns for test execution.void
setExecutable
(Object executable) Sets the name of the executable to use.void
setExecutable
(String 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.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
setJvmArgs
(List<String> 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
setMinHeapSize
(String heapSize) Sets the minimum heap size for the process.void
setScanForTestClasses
(boolean scanForTestClasses) void
setSystemProperties
(Map<String, ?> properties) Sets the system properties to use for the process.void
setTestClassesDir
(File testClassesDir) Deprecated.void
setTestClassesDirs
(FileCollection testClassesDirs) Sets the directories to scan for compiled test sources.setTestNameIncludePatterns
(List<String> testNamePattern) Sets the test name patterns to be included in execution.void
setWorkingDir
(File dir) Sets the working directory for the process.void
setWorkingDir
(Object dir) Sets the working directory for the process.systemProperties
(Map<String, ?> properties) Adds some system properties to use for the process.systemProperty
(String name, Object value) Adds a system property to use for the process.org.gradle.api.internal.tasks.testing.TestFramework
testFramework
(Closure testFrameworkConfigure) void
useJUnit()
Specifies that JUnit should be used to execute the tests.void
Specifies that JUnit should be used to execute the tests, configuring JUnit specific options.void
useJUnit
(Action<? super JUnitOptions> testFrameworkConfigure) Specifies that JUnit should be used to execute the tests, configuring JUnit specific options.void
Specifies that TestNG should be used to execute the tests.void
Specifies that TestNG should be used to execute the tests, configuring TestNG specific options.void
useTestNG
(Action<? super TestFrameworkOptions> testFrameworkConfigure) Specifies that TestNG should be used to execute the tests, configuring TestNG specific options.workingDir
(Object dir) Sets the working directory for the process.Methods inherited from class org.gradle.api.tasks.testing.AbstractTestTask
addTestListener, addTestOutputListener, afterSuite, afterTest, beforeSuite, beforeTest, getBinaryResultsDirectory, getBinResultsDir, getBuildOperationExecutor, getIgnoreFailures, getInetAddressFactory, getInstantiator, getListenerManager, getProgressLoggerFactory, getReports, getTestLogging, getTextOutputFactory, onOutput, removeTestListener, removeTestOutputListener, reports, reports, setBinResultsDir, setIgnoreFailures, testLogging, testLogging
Methods inherited from class org.gradle.api.internal.ConventionTask
conventionMapping, conventionMapping, getConventionMapping
Methods inherited from class org.gradle.api.DefaultTask
newInputDirectory, newInputFile, newOutputDirectory, newOutputFile
Methods 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
-
Test
public Test()
-
-
Method Details
-
getActorFactory
@Inject protected org.gradle.internal.actor.ActorFactory getActorFactory() -
getClassLoaderCache
@Inject protected org.gradle.api.internal.initialization.loadercache.ClassLoaderCache getClassLoaderCache() -
getProcessBuilderFactory
@Inject protected org.gradle.process.internal.worker.WorkerProcessFactory getProcessBuilderFactory() -
getFileResolver
@Inject protected org.gradle.api.internal.file.FileResolver getFileResolver() -
getModuleRegistry
@Inject protected org.gradle.api.internal.classpath.ModuleRegistry getModuleRegistry() -
getWorkingDir
Returns the working directory for the process. Defaults to the project directory.- Specified by:
getWorkingDir
in interfaceProcessForkOptions
- Returns:
- The working directory. Never returns null.
-
setWorkingDir
Sets the working directory for the process.- Specified by:
setWorkingDir
in interfaceProcessForkOptions
- Parameters:
dir
- The working directory. Must not be null.
-
setWorkingDir
Sets the working directory for the process. The supplied argument is evaluated as perProject.file(Object)
.- Specified by:
setWorkingDir
in interfaceProcessForkOptions
- Parameters:
dir
- The working directory. Must not be null.
-
workingDir
Sets the working directory for the process. The supplied argument is evaluated as perProject.file(Object)
.- Specified by:
workingDir
in interfaceProcessForkOptions
- Parameters:
dir
- The working directory. Must not be null.- Returns:
- this
-
getJavaVersion
Returns the version of Java used to run the tests based on the executable specified bygetExecutable()
.- Since:
- 3.3
-
getExecutable
Returns the name of the executable to use.- Specified by:
getExecutable
in interfaceProcessForkOptions
- Returns:
- The executable.
-
executable
Sets the name of the executable to use.- Specified by:
executable
in interfaceProcessForkOptions
- Parameters:
executable
- The executable. Must not be null.- Returns:
- this
-
setExecutable
Sets the name of the executable to use.- Specified by:
setExecutable
in interfaceProcessForkOptions
- Parameters:
executable
- The executable. Must not be null.
-
setExecutable
Sets the name of the executable to use.- Specified by:
setExecutable
in interfaceProcessForkOptions
- Parameters:
executable
- The executable. Must not be null.
-
getSystemProperties
Returns the system properties which will be used for the process.- Specified by:
getSystemProperties
in interfaceJavaForkOptions
- Returns:
- The system properties. Returns an empty map when there are no system properties.
-
setSystemProperties
Sets the system properties to use for the process.- Specified by:
setSystemProperties
in interfaceJavaForkOptions
- Parameters:
properties
- The system properties. Must not be null.
-
systemProperties
Adds some system properties to use for the process.- Specified by:
systemProperties
in interfaceJavaForkOptions
- Parameters:
properties
- The system properties. Must not be null.- Returns:
- this
-
systemProperty
Adds a system property to use for the process.- Specified by:
systemProperty
in interfaceJavaForkOptions
- Parameters:
name
- The name of the propertyvalue
- The value for the property. May be null.- Returns:
- this
-
getBootstrapClasspath
Returns the bootstrap classpath to use for the process. The default bootstrap classpath for the JVM is used when this classpath is empty.- Specified by:
getBootstrapClasspath
in interfaceJavaForkOptions
- Returns:
- The bootstrap classpath. Never returns null.
-
setBootstrapClasspath
Sets the bootstrap classpath to use for the process. Set to an empty classpath to use the default bootstrap classpath for the specified JVM.- Specified by:
setBootstrapClasspath
in interfaceJavaForkOptions
- Parameters:
classpath
- The classpath. Must not be null. Can be empty.
-
bootstrapClasspath
Adds the given values to the end of the bootstrap classpath for the process.- Specified by:
bootstrapClasspath
in interfaceJavaForkOptions
- Parameters:
classpath
- The classpath.- Returns:
- this
-
getMinHeapSize
Returns the minimum heap size for the process, if any.- Specified by:
getMinHeapSize
in interfaceJavaForkOptions
- Returns:
- The minimum heap size. Returns null if the default minimum heap size should be used.
-
getDefaultCharacterEncoding
Returns the default character encoding to use.- Specified by:
getDefaultCharacterEncoding
in interfaceJavaForkOptions
- Returns:
- The default character encoding. Returns null if the
default character encoding of this JVM
should be used.
-
setDefaultCharacterEncoding
Sets the default character encoding to use. Note: Many JVM implementations support the setting of this attribute via system property on startup (namely, thefile.encoding
property). For JVMs where this is the case, setting thefile.encoding
property viaJavaForkOptions.setSystemProperties(java.util.Map)
or similar will have no effect as this value will be overridden by the value specified byJavaForkOptions.getDefaultCharacterEncoding()
.- Specified by:
setDefaultCharacterEncoding
in interfaceJavaForkOptions
- Parameters:
defaultCharacterEncoding
- The default character encoding. Use null to usethis JVM's default charset
-
setMinHeapSize
Sets the minimum heap size for the process.- Specified by:
setMinHeapSize
in interfaceJavaForkOptions
- Parameters:
heapSize
- The minimum heap size. Use null for the default minimum heap size.
-
getMaxHeapSize
Returns the maximum heap size for the process, if any.- Specified by:
getMaxHeapSize
in interfaceJavaForkOptions
- Returns:
- The maximum heap size. Returns null if the default maximum heap size should be used.
-
setMaxHeapSize
Sets the maximum heap size for the process.- Specified by:
setMaxHeapSize
in interfaceJavaForkOptions
- Parameters:
heapSize
- The heap size. Use null for the default maximum heap size.
-
getJvmArgs
Returns the extra arguments to use to launch the JVM for the process. Does not include system properties and the minimum/maximum heap size.- Specified by:
getJvmArgs
in interfaceJavaForkOptions
- Returns:
- The arguments. Returns an empty list if there are no arguments.
-
setJvmArgs
Sets the extra arguments to use to launch the JVM for the process. System properties and minimum/maximum heap size are updated.- Specified by:
setJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
setJvmArgs
Sets the extra arguments to use to launch the JVM for the process. System properties and minimum/maximum heap size are updated.- Specified by:
setJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
jvmArgs
Adds some arguments to use to launch the JVM for the process.- Specified by:
jvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.- Returns:
- this
-
jvmArgs
Adds some arguments to use to launch the JVM for the process.- Specified by:
jvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments.- Returns:
- this
-
getEnableAssertions
public boolean getEnableAssertions()Returns true if assertions are enabled for the process.- Specified by:
getEnableAssertions
in interfaceJavaForkOptions
- Returns:
- true if assertions are enabled, false if disabled
-
setEnableAssertions
public void setEnableAssertions(boolean enabled) Enable or disable assertions for the process.- Specified by:
setEnableAssertions
in interfaceJavaForkOptions
- Parameters:
enabled
- true to enable assertions, false to disable.
-
getDebug
public boolean getDebug()Returns true if debugging is enabled for the process. When enabled, the process is started suspended and listening on port 5005.- Specified by:
getDebug
in interfaceJavaForkOptions
- Returns:
- true when debugging is enabled, false to disable.
-
setDebug
public void setDebug(boolean enabled) Enable or disable debugging for the process. When enabled, the process is started suspended and listening on port 5005.- Specified by:
setDebug
in interfaceJavaForkOptions
- Parameters:
enabled
- true to enable debugging, false to disable.
-
getAllJvmArgs
Returns the full set of arguments to use to launch the JVM for the process. This includes arguments to define system properties, the minimum/maximum heap size, and the bootstrap classpath.- Specified by:
getAllJvmArgs
in interfaceJavaForkOptions
- Returns:
- The arguments. Returns an empty list if there are no arguments.
-
setAllJvmArgs
Sets the full set of arguments to use to launch the JVM for the process. Overwrites any previously set system properties, minimum/maximum heap size, assertions, and bootstrap classpath.- Specified by:
setAllJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
setAllJvmArgs
Sets the full set of arguments to use to launch the JVM for the process. Overwrites any previously set system properties, minimum/maximum heap size, assertions, and bootstrap classpath.- Specified by:
setAllJvmArgs
in interfaceJavaForkOptions
- Parameters:
arguments
- The arguments. Must not be null.
-
getEnvironment
The environment variables to use for the process. Defaults to the environment of this process.- Specified by:
getEnvironment
in interfaceProcessForkOptions
- Returns:
- The environment. Returns an empty map when there are no environment variables.
-
environment
Adds some environment variables to the environment for this process.- Specified by:
environment
in interfaceProcessForkOptions
- Parameters:
environmentVariables
- The environment variables. Must not be null.- Returns:
- this
-
environment
Adds an environment variable to the environment for this process.- Specified by:
environment
in interfaceProcessForkOptions
- Parameters:
name
- The name of the variable.value
- The value for the variable. Must not be null.- Returns:
- this
-
setEnvironment
Sets the environment variable to use for the process.- Specified by:
setEnvironment
in interfaceProcessForkOptions
- Parameters:
environmentVariables
- The environment variables. Must not be null.
-
copyTo
Copies these options to the given target options.- Specified by:
copyTo
in interfaceProcessForkOptions
- Parameters:
target
- The target options- Returns:
- this
-
copyTo
Copies these options to the given options.- Specified by:
copyTo
in interfaceJavaForkOptions
- Parameters:
target
- The target options.- Returns:
- this
-
createTestExecutionSpec
protected org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec createTestExecutionSpec()Creates test execution specification. For internal use only.- Specified by:
createTestExecutionSpec
in classAbstractTestTask
- Since:
- 4.4
-
executeTests
public void executeTests()- Overrides:
executeTests
in classAbstractTestTask
-
createTestExecuter
protected org.gradle.api.internal.tasks.testing.TestExecuter<org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec> createTestExecuter()Description copied from class:AbstractTestTask
Creates test executer. For internal use only.- Specified by:
createTestExecuter
in classAbstractTestTask
-
include
Adds include patterns for the files in the test classes directory (e.g. '**/*Test.class')).- Specified by:
include
in interfacePatternFilterable
- Parameters:
includes
- a vararg list of include patterns- Returns:
- this
- See Also:
-
include
Adds include patterns for the files in the test classes directory (e.g. '**/*Test.class')).- Specified by:
include
in interfacePatternFilterable
- Parameters:
includes
- a Iterable providing more include patterns- Returns:
- this
- See Also:
-
include
Adds an include spec. This method may be called multiple times to append new specs. 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.- Specified by:
include
in interfacePatternFilterable
- Parameters:
includeSpec
- the spec to add- Returns:
- this
- See Also:
-
include
Adds an include spec. This method may be called multiple times to append new specs. The given closure is passed aFileTreeElement
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.- Specified by:
include
in interfacePatternFilterable
- Parameters:
includeSpec
- the spec to add- Returns:
- this
- See Also:
-
exclude
Adds exclude patterns for the files in the test classes directory (e.g. '**/*Test.class')).- Specified by:
exclude
in interfacePatternFilterable
- Parameters:
excludes
- a vararg list of exclude patterns- Returns:
- this
- See Also:
-
exclude
Adds exclude patterns for the files in the test classes directory (e.g. '**/*Test.class')).- Specified by:
exclude
in interfacePatternFilterable
- Parameters:
excludes
- a Iterable providing new exclude patterns- Returns:
- this
- See Also:
-
exclude
Adds an exclude spec. This method may be called multiple times to append new specs. 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.- Specified by:
exclude
in interfacePatternFilterable
- Parameters:
excludeSpec
- the spec to add- Returns:
- this
- See Also:
-
exclude
Adds an exclude spec. This method may be called multiple times to append new specs.The given closure is passed aFileTreeElement
as its parameter. The closure should return true or false. Example:copySpec { from 'source' into 'destination' //an example of excluding files from certain configuration: exclude { it.file in configurations.someConf.files } }
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.- Specified by:
exclude
in interfacePatternFilterable
- Parameters:
excludeSpec
- the spec to add- Returns:
- this
- See Also:
-
setTestNameIncludePatterns
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 seeTestFilter
-
getTestClassesDir
Deprecated.UsegetTestClassesDirs()
.Returns the root folder for the compiled test sources.- Returns:
- All test class directories to be used.
-
setTestClassesDir
Deprecated.Sets the root folder for the compiled test sources.- Parameters:
testClassesDir
- The root folder
-
getTestClassesDirs
Returns the directories for the compiled test sources.- Returns:
- All test class directories to be used.
- Since:
- 4.0
-
setTestClassesDirs
Sets the directories to scan for compiled test sources. Typically, this would be configured to use the output of a source set:apply plugin: 'java' sourceSets { integrationTest { compileClasspath += main.output runtimeClasspath += main.output } } task integrationTest(type: Test) { // Runs tests from src/integrationTest testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath }
- Parameters:
testClassesDirs
- All test class directories to be used.- Since:
- 4.0
-
getIncludes
Returns the include patterns for test execution.- Specified by:
getIncludes
in interfacePatternFilterable
- Returns:
- The include patterns. Returns an empty set when there are no include patterns.
- See Also:
-
setIncludes
Sets the include patterns for test execution.- Specified by:
setIncludes
in interfacePatternFilterable
- Parameters:
includes
- The patterns list- Returns:
- this
- See Also:
-
getExcludes
Returns the exclude patterns for test execution.- Specified by:
getExcludes
in interfacePatternFilterable
- Returns:
- The exclude patterns. Returns an empty set when there are no exclude patterns.
- See Also:
-
setExcludes
Sets the exclude patterns for test execution.- Specified by:
setExcludes
in interfacePatternFilterable
- Parameters:
excludes
- The patterns list- Returns:
- this
- See Also:
-
getTestFramework
-
testFramework
public org.gradle.api.internal.tasks.testing.TestFramework testFramework(Closure testFrameworkConfigure) -
getOptions
Returns test framework specific options. Make sure to calluseJUnit()
oruseTestNG()
before using this method.- Returns:
- The test framework options.
-
options
Configures test framework specific options. Make sure to calluseJUnit()
oruseTestNG()
before using this method.- Returns:
- The test framework options.
-
options
Configures test framework specific options. Make sure to calluseJUnit()
oruseTestNG()
before using this method.- Returns:
- The test framework options.
- Since:
- 3.5
-
useJUnit
public void useJUnit()Specifies that JUnit should be used to execute the tests.To configure JUnit specific options, see
useJUnit(groovy.lang.Closure)
. -
useJUnit
Specifies that JUnit should be used to execute the tests, configuring JUnit specific options.The supplied closure configures an instance of
JUnitOptions
, which can be used to configure how JUnit runs.- Parameters:
testFrameworkConfigure
- A closure used to configure the JUnit options.
-
useJUnit
Specifies that JUnit should be used to execute the tests, configuring JUnit specific options.The supplied action configures an instance of
JUnitOptions
, which can be used to configure how JUnit runs.- Parameters:
testFrameworkConfigure
- An action used to configure the JUnit options.- Since:
- 3.5
-
useTestNG
public void useTestNG()Specifies that TestNG should be used to execute the tests.To configure TestNG specific options, see
useTestNG(Closure)
. -
useTestNG
Specifies that TestNG should be used to execute the tests, configuring TestNG specific options.The supplied closure configures an instance of
TestNGOptions
, which can be used to configure how TestNG runs.- Parameters:
testFrameworkConfigure
- A closure used to configure the TestNG options.
-
useTestNG
Specifies that TestNG should be used to execute the tests, configuring TestNG specific options.The supplied action configures an instance of
TestNGOptions
, which can be used to configure how TestNG runs.- Parameters:
testFrameworkConfigure
- An action used to configure the TestNG options.- Since:
- 3.5
-
getClasspath
Returns the classpath to use to execute the tests. -
setClasspath
-
isScanForTestClasses
Specifies whether test classes should be detected. Whentrue
the classes which match the include and exclude patterns are scanned for test classes, and any found are executed. Whenfalse
the classes which match the include and exclude patterns are executed. -
setScanForTestClasses
public void setScanForTestClasses(boolean scanForTestClasses) -
getForkEvery
Returns the maximum number of test classes to execute in a forked test process. The forked test process will be restarted when this limit is reached. The default value is 0 (no maximum).- Returns:
- The maximum number of test classes. Returns 0 when there is no maximum.
-
setForkEvery
Sets the maximum number of test classes to execute in a forked test process. Use null or 0 to use no maximum.- Parameters:
forkEvery
- The maximum number of test classes. Use null or 0 to specify no maximum.
-
getMaxParallelForks
Returns the maximum number of forked test processes to execute in parallel. The default value is 1 (no parallel test execution). It cannot exceed the value of max-workers for the current build.- Returns:
- The maximum number of forked test processes.
-
setMaxParallelForks
public void setMaxParallelForks(int maxParallelForks) Sets the maximum number of forked test processes to execute in parallel. Set to 1 to disable parallel test execution.- Parameters:
maxParallelForks
- The maximum number of forked test processes.
-
getCandidateClassFiles
Returns the classes files to scan for test classes.- Returns:
- The candidate class files.
-
getFilter
Allows filtering tests for execution.- Returns:
- filter object
- Since:
- 1.10
-
filter
Executes the action against thegetFilter()
.- Parameters:
action
- configuration of the test filter- Since:
- 1.10
-
getTestClassesDirs()
.