java.lang.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
, Configurable<Task>
@NonNullApi @CacheableTask public abstract class Test extends AbstractTestTask implements JavaForkOptions, PatternFilterable
The sample below shows various configuration options.
plugins { id 'java' // adds 'test' task } test { // Discover and execute JUnit4-based tests useJUnit() // Discover and execute TestNG-based tests useTestNG() // Discover and execute JUnit Platform-based tests useJUnitPlatform() // 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) } // Fail the 'test' task on the first test failure failFast = true // 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
Task.Namer
TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE
Constructor | Description |
---|---|
Test() |
Modifier and Type | Method | Description |
---|---|---|
Test |
bootstrapClasspath(java.lang.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.
|
protected org.gradle.api.internal.tasks.testing.TestExecuter<org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec> |
createTestExecuter() |
Creates test executer.
|
protected org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec |
createTestExecutionSpec() |
Creates test execution specification.
|
void |
debugOptions(Action<JavaDebugOptions> action) |
Configures Java Debug Wire Protocol properties for the process.
|
Test |
environment(java.lang.String name,
java.lang.Object value) |
Adds an environment variable to the environment for this process.
|
Test |
environment(java.util.Map<java.lang.String,?> environmentVariables) |
Adds some environment variables to the environment for this process.
|
Test |
exclude(Closure excludeSpec) |
Adds an exclude spec.
|
Test |
exclude(java.lang.Iterable<java.lang.String> excludes) |
Adds exclude patterns for the files in the test classes directory (e.g.
|
Test |
exclude(java.lang.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 |
executable(java.lang.Object executable) |
Sets the name of the executable to use.
|
void |
executeTests() |
|
void |
filter(Action<TestFilter> action) |
Executes the action against the
AbstractTestTask.getFilter() . |
protected org.gradle.internal.actor.ActorFactory |
getActorFactory() |
|
java.util.List<java.lang.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() |
Returns the classpath to use to execute the tests.
|
boolean |
getDebug() |
Determines whether debugging is enabled for the test process.
|
JavaDebugOptions |
getDebugOptions() |
Returns the Java Debug Wire Protocol properties for the process.
|
java.lang.String |
getDefaultCharacterEncoding() |
Returns the default character encoding to use.
|
boolean |
getEnableAssertions() |
Returns true if assertions are enabled for the process.
|
java.util.Map<java.lang.String,java.lang.Object> |
getEnvironment() |
The environment variables to use for the process.
|
java.util.Set<java.lang.String> |
getExcludes() |
Returns the exclude patterns for test execution.
|
java.lang.String |
getExecutable() |
Returns the name of the executable to use.
|
boolean |
getFailFast() |
Indicates if this task will fail on the first failed test
|
long |
getForkEvery() |
Returns the maximum number of test classes to execute in a forked test process.
|
protected org.gradle.process.internal.JavaForkOptionsFactory |
getForkOptionsFactory() |
|
java.util.Set<java.lang.String> |
getIncludes() |
Returns the include patterns for test execution.
|
Property<JavaLauncher> |
getJavaLauncher() |
Configures the java executable to be used to run the tests.
|
protected org.gradle.internal.jvm.JavaModuleDetector |
getJavaModuleDetector() |
|
protected JavaToolchainService |
getJavaToolchainService() |
|
JavaVersion |
getJavaVersion() |
Returns the version of Java used to run the tests based on the
JavaLauncher specified by getJavaLauncher() ,
or the executable specified by getExecutable() if the JavaLauncher is not present. |
java.util.List<java.lang.String> |
getJvmArgs() |
Returns the extra arguments to use to launch the JVM for the process.
|
java.util.List<CommandLineArgumentProvider> |
getJvmArgumentProviders() |
Command line argument providers for the java process to fork.
|
java.lang.String |
getMaxHeapSize() |
Returns the maximum heap size for the process, if any.
|
int |
getMaxParallelForks() |
Returns the maximum number of test processes to start in parallel.
|
java.lang.String |
getMinHeapSize() |
Returns the minimum heap size for the process, if any.
|
ModularitySpec |
getModularity() |
Returns the module path handling of this test task.
|
protected org.gradle.api.internal.classpath.ModuleRegistry |
getModuleRegistry() |
|
protected java.util.List<java.lang.String> |
getNoMatchingTestErrorReasons() |
Returns the reasons for no matching test error.
|
protected ObjectFactory |
getObjectFactory() |
|
TestFrameworkOptions |
getOptions() |
Returns test framework specific options.
|
protected org.gradle.internal.Factory<PatternSet> |
getPatternSetFactory() |
|
protected org.gradle.process.internal.worker.WorkerProcessFactory |
getProcessBuilderFactory() |
|
protected ProviderFactory |
getProviderFactory() |
|
protected FileCollection |
getStableClasspath() |
Returns the classpath to use to execute the tests.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSystemProperties() |
Returns the system properties which will be used for the process.
|
FileCollection |
getTestClassesDirs() |
Returns the directories for the compiled test sources.
|
org.gradle.api.internal.tasks.testing.TestFramework |
getTestFramework() |
|
Property<org.gradle.api.internal.tasks.testing.TestFramework> |
getTestFrameworkProperty() |
Returns the configured
TestFramework . |
java.io.File |
getWorkingDir() |
Returns the working directory for the process.
|
Test |
include(Closure includeSpec) |
Adds an include spec.
|
Test |
include(java.lang.Iterable<java.lang.String> includes) |
Adds include patterns for the files in the test classes directory (e.g.
|
Test |
include(java.lang.String... includes) |
Adds include patterns for the files in the test classes directory (e.g.
|
Test |
include(Spec<FileTreeElement> includeSpec) |
Adds an include spec.
|
boolean |
isScanForTestClasses() |
Specifies whether test classes should be detected.
|
Test |
jvmArgs(java.lang.Iterable<?> arguments) |
Adds some arguments to use to launch the JVM for the process.
|
Test |
jvmArgs(java.lang.Object... arguments) |
Adds some arguments to use to launch the JVM for the process.
|
TestFrameworkOptions |
options(Closure testFrameworkConfigure) |
Configures test framework specific options.
|
TestFrameworkOptions |
options(Action<? super TestFrameworkOptions> testFrameworkConfigure) |
Configures test framework specific options.
|
void |
setAllJvmArgs(java.lang.Iterable<?> arguments) |
Sets the full set of arguments to use to launch the JVM for the process.
|
void |
setAllJvmArgs(java.util.List<java.lang.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(java.lang.String defaultCharacterEncoding) |
Sets the default character encoding to use.
|
void |
setEnableAssertions(boolean enabled) |
Enable or disable assertions for the process.
|
void |
setEnvironment(java.util.Map<java.lang.String,?> environmentVariables) |
Sets the environment variable to use for the process.
|
Test |
setExcludes(java.lang.Iterable<java.lang.String> excludes) |
Sets the exclude patterns for test execution.
|
void |
setExecutable(java.lang.Object executable) |
Sets the name of the executable to use.
|
void |
setExecutable(java.lang.String executable) |
Sets the name of the executable to use.
|
void |
setFailFast(boolean failFast) |
Enables fail fast behavior causing the task to fail on the first failed test.
|
void |
setForkEvery(java.lang.Long forkEvery) |
Sets the maximum number of test classes to execute in a forked test process.
|
Test |
setIncludes(java.lang.Iterable<java.lang.String> includes) |
Sets the include patterns for test execution.
|
void |
setJvmArgs(java.lang.Iterable<?> arguments) |
Sets the extra arguments to use to launch the JVM for the process.
|
void |
setJvmArgs(java.util.List<java.lang.String> arguments) |
Sets the extra arguments to use to launch the JVM for the process.
|
void |
setMaxHeapSize(java.lang.String heapSize) |
Sets the maximum heap size for the process.
|
void |
setMaxParallelForks(int maxParallelForks) |
Sets the maximum number of test processes to start in parallel.
|
void |
setMinHeapSize(java.lang.String heapSize) |
Sets the minimum heap size for the process.
|
void |
setScanForTestClasses(boolean scanForTestClasses) |
|
void |
setSystemProperties(java.util.Map<java.lang.String,?> properties) |
Sets the system properties to use for the process.
|
void |
setTestClassesDirs(FileCollection testClassesDirs) |
Sets the directories to scan for compiled test sources.
|
Test |
setTestNameIncludePatterns(java.util.List<java.lang.String> testNamePattern) |
Sets the test name patterns to be included in execution.
|
void |
setWorkingDir(java.io.File dir) |
Sets the working directory for the process.
|
void |
setWorkingDir(java.lang.Object dir) |
Sets the working directory for the process.
|
Test |
systemProperties(java.util.Map<java.lang.String,?> properties) |
Adds some system properties to use for the process.
|
Test |
systemProperty(java.lang.String name,
java.lang.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 JUnit4 should be used to discover and execute the tests.
|
void |
useJUnit(Closure testFrameworkConfigure) |
Specifies that JUnit4 should be used to discover and execute the tests with additional configuration.
|
void |
useJUnit(Action<? super JUnitOptions> testFrameworkConfigure) |
Specifies that JUnit4 should be used to discover and execute the tests with additional configuration.
|
void |
useJUnitPlatform() |
Specifies that JUnit Platform should be used to discover and execute the tests.
|
void |
useJUnitPlatform(Action<? super JUnitPlatformOptions> testFrameworkConfigure) |
Specifies that JUnit Platform should be used to discover and execute the tests with additional configuration.
|
void |
useTestNG() |
Specifies that TestNG should be used to discover and execute the tests.
|
void |
useTestNG(Closure testFrameworkConfigure) |
Specifies that TestNG should be used to discover and execute the tests with additional configuration.
|
void |
useTestNG(Action<? super TestNGOptions> testFrameworkConfigure) |
Specifies that TestNG should be used to discover and execute the tests with additional configuration.
|
Test |
workingDir(java.lang.Object dir) |
Sets the working directory for the process.
|
addTestListener, addTestOutputListener, afterSuite, afterTest, beforeSuite, beforeTest, getBinaryResultsDirectory, getBuildOperationExecutor, getFileSystemOperations, getFilter, getHostnameLookup, getIgnoreFailures, getInstantiator, getListenerManager, getProgressLoggerFactory, getReports, getTestLogging, getTextOutputFactory, onOutput, removeTestListener, removeTestOutputListener, reports, reports, setIgnoreFailures, testLogging, testLogging
conventionMapping, conventionMapping, getConventionMapping
compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService
appendParallelSafeAction, doNotTrackState, getAsDynamicObject, getConvention, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getOnlyIf, getReasonNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, setImpliesSubProjects
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
doNotTrackState, getConvention, notCompatibleWithConfigurationCache
@Internal public java.io.File getWorkingDir()
getWorkingDir
in interface ProcessForkOptions
public void setWorkingDir(java.io.File dir)
setWorkingDir
in interface ProcessForkOptions
dir
- The working directory. Must not be null.public void setWorkingDir(java.lang.Object dir)
Project.file(Object)
.setWorkingDir
in interface ProcessForkOptions
dir
- The working directory. Must not be null.public Test workingDir(java.lang.Object dir)
Project.file(Object)
.workingDir
in interface ProcessForkOptions
dir
- The working directory. Must not be null.@Input public JavaVersion getJavaVersion()
JavaLauncher
specified by getJavaLauncher()
,
or the executable specified by getExecutable()
if the JavaLauncher
is not present.@Internal public java.lang.String getExecutable()
getExecutable
in interface ProcessForkOptions
public Test executable(java.lang.Object executable)
executable
in interface ProcessForkOptions
executable
- The executable. Must not be null.public void setExecutable(java.lang.String executable)
setExecutable
in interface ProcessForkOptions
executable
- The executable. Must not be null.public void setExecutable(java.lang.Object executable)
setExecutable
in interface ProcessForkOptions
executable
- The executable. Must not be null.public java.util.Map<java.lang.String,java.lang.Object> getSystemProperties()
getSystemProperties
in interface JavaForkOptions
public void setSystemProperties(java.util.Map<java.lang.String,?> properties)
setSystemProperties
in interface JavaForkOptions
properties
- The system properties. Must not be null.public Test systemProperties(java.util.Map<java.lang.String,?> properties)
systemProperties
in interface JavaForkOptions
properties
- The system properties. Must not be null.public Test systemProperty(java.lang.String name, java.lang.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(java.lang.Object... classpath)
bootstrapClasspath
in interface JavaForkOptions
classpath
- The classpath.public java.lang.String getMinHeapSize()
getMinHeapSize
in interface JavaForkOptions
public java.lang.String getDefaultCharacterEncoding()
getDefaultCharacterEncoding
in interface JavaForkOptions
default character encoding of this JVM
should be used.public void setDefaultCharacterEncoding(java.lang.String defaultCharacterEncoding)
file.encoding
property). For JVMs
where this is the case, setting the file.encoding
property via JavaForkOptions.setSystemProperties(java.util.Map)
or similar will have no effect as
this value will be overridden by the value specified by JavaForkOptions.getDefaultCharacterEncoding()
.setDefaultCharacterEncoding
in interface JavaForkOptions
defaultCharacterEncoding
- The default character encoding. Use null to use this JVM's default charset
public void setMinHeapSize(java.lang.String heapSize)
setMinHeapSize
in interface JavaForkOptions
heapSize
- The minimum heap size. Use null for the default minimum heap size.public java.lang.String getMaxHeapSize()
getMaxHeapSize
in interface JavaForkOptions
public void setMaxHeapSize(java.lang.String heapSize)
setMaxHeapSize
in interface JavaForkOptions
heapSize
- The heap size. Use null for the default maximum heap size.public java.util.List<java.lang.String> getJvmArgs()
getJvmArgs
in interface JavaForkOptions
public java.util.List<CommandLineArgumentProvider> getJvmArgumentProviders()
getJvmArgumentProviders
in interface JavaForkOptions
public void setJvmArgs(java.util.List<java.lang.String> arguments)
setJvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.public void setJvmArgs(java.lang.Iterable<?> arguments)
setJvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.public Test jvmArgs(java.lang.Iterable<?> arguments)
jvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.public Test jvmArgs(java.lang.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()
debug = true
— the process
is started in a suspended state, listening on port 5005. You should disable parallel test execution when
debugging and you will need to reattach the debugger occasionally if you use a non-zero value for
getForkEvery()
.
Since Gradle 5.6, you can configure the port and other Java debug properties via
JavaForkOptions.debugOptions(Action)
.
getDebug
in interface JavaForkOptions
public void setDebug(boolean enabled)
The debug properties (e.g. the port number) can be configured in JavaForkOptions.debugOptions(Action)
.
setDebug
in interface JavaForkOptions
enabled
- true to enable debugging, false to disable.public JavaDebugOptions getDebugOptions()
-agentlib:jdwp=...
will be appended to the JVM arguments with the configuration from the parameter.getDebugOptions
in interface JavaForkOptions
public void debugOptions(Action<JavaDebugOptions> action)
JavaForkOptions.setDebug(boolean)
is enabled then
the -agentlib:jdwp=...
will be appended to the JVM arguments with the configuration from the parameter.debugOptions
in interface JavaForkOptions
action
- the Java debug configurationpublic void setFailFast(boolean failFast)
public boolean getFailFast()
public java.util.List<java.lang.String> getAllJvmArgs()
getAllJvmArgs
in interface JavaForkOptions
public void setAllJvmArgs(java.util.List<java.lang.String> arguments)
setAllJvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.public void setAllJvmArgs(java.lang.Iterable<?> arguments)
setAllJvmArgs
in interface JavaForkOptions
arguments
- The arguments. Must not be null.@Internal public java.util.Map<java.lang.String,java.lang.Object> getEnvironment()
getEnvironment
in interface ProcessForkOptions
public Test environment(java.util.Map<java.lang.String,?> environmentVariables)
environment
in interface ProcessForkOptions
environmentVariables
- The environment variables. Must not be null.public Test environment(java.lang.String name, java.lang.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(java.util.Map<java.lang.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 optionspublic Test copyTo(JavaForkOptions target)
copyTo
in interface JavaForkOptions
target
- The target options.public ModularitySpec getModularity()
protected org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec createTestExecutionSpec()
createTestExecutionSpec
in class AbstractTestTask
public void executeTests()
executeTests
in class AbstractTestTask
protected org.gradle.api.internal.tasks.testing.TestExecuter<org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec> createTestExecuter()
AbstractTestTask
createTestExecuter
in class AbstractTestTask
protected java.util.List<java.lang.String> getNoMatchingTestErrorReasons()
AbstractTestTask
getNoMatchingTestErrorReasons
in class AbstractTestTask
public Test include(java.lang.String... includes)
include
in interface PatternFilterable
includes
- a vararg list of include patternssetIncludes(Iterable)
public Test include(java.lang.Iterable<java.lang.String> includes)
include
in interface PatternFilterable
includes
- a Iterable providing more include patternssetIncludes(Iterable)
public Test include(Spec<FileTreeElement> includeSpec)
include
in interface PatternFilterable
includeSpec
- the spec to addPattern Format
public Test include(Closure includeSpec)
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 addPattern Format
public Test exclude(java.lang.String... excludes)
exclude
in interface PatternFilterable
excludes
- a vararg list of exclude patternssetExcludes(Iterable)
public Test exclude(java.lang.Iterable<java.lang.String> excludes)
exclude
in interface PatternFilterable
excludes
- a Iterable providing new exclude patternssetExcludes(Iterable)
public Test exclude(Spec<FileTreeElement> excludeSpec)
exclude
in interface PatternFilterable
excludeSpec
- the spec to addPattern Format
public Test exclude(Closure excludeSpec)
FileTreeElement
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.
exclude
in interface PatternFilterable
excludeSpec
- the spec to addFileTreeElement
public Test setTestNameIncludePatterns(java.util.List<java.lang.String> testNamePattern)
TestFilter
setTestNameIncludePatterns
in class AbstractTestTask
@Internal public FileCollection getTestClassesDirs()
public void setTestClassesDirs(FileCollection testClassesDirs)
plugins { id '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 }
testClassesDirs
- All test class directories to be used.@Internal public java.util.Set<java.lang.String> getIncludes()
getIncludes
in interface PatternFilterable
include(String...)
public Test setIncludes(java.lang.Iterable<java.lang.String> includes)
setIncludes
in interface PatternFilterable
includes
- The patterns listinclude(String...)
@Internal public java.util.Set<java.lang.String> getExcludes()
getExcludes
in interface PatternFilterable
exclude(String...)
public Test setExcludes(java.lang.Iterable<java.lang.String> excludes)
setExcludes
in interface PatternFilterable
excludes
- The patterns listexclude(String...)
public Property<org.gradle.api.internal.tasks.testing.TestFramework> getTestFrameworkProperty()
TestFramework
.@Internal public org.gradle.api.internal.tasks.testing.TestFramework getTestFramework()
public org.gradle.api.internal.tasks.testing.TestFramework testFramework(@Nullable Closure testFrameworkConfigure)
public TestFrameworkOptions getOptions()
useJUnit()
, useJUnitPlatform()
or useTestNG()
before using this method.public TestFrameworkOptions options(@DelegatesTo(TestFrameworkOptions.class) Closure testFrameworkConfigure)
When a Test
task is created outside of Test Suites, you should call useJUnit()
, useJUnitPlatform()
or useTestNG()
before using this method.
If no test framework has been set, the task will assume JUnit4.
public TestFrameworkOptions options(Action<? super TestFrameworkOptions> testFrameworkConfigure)
When a Test
task is created outside of Test Suites, you should call useJUnit()
, useJUnitPlatform()
or useTestNG()
before using this method.
If no test framework has been set, the task will assume JUnit4.
public void useJUnit()
Configure JUnit4 specific options.
public void useJUnit(@Nullable @DelegatesTo(JUnitOptions.class) Closure testFrameworkConfigure)
The supplied action configures an instance of JUnit4 specific options
.
testFrameworkConfigure
- A closure used to configure JUnit4 options.public void useJUnit(Action<? super JUnitOptions> testFrameworkConfigure)
The supplied action configures an instance of JUnit4 specific options
.
testFrameworkConfigure
- An action used to configure JUnit4 options.public void useJUnitPlatform()
Use this option if your tests use JUnit Jupiter/JUnit5.
JUnit Platform supports multiple test engines, which allows other testing frameworks to be built on top of it. You may need to use this option even if you are not using JUnit directly.
Configure JUnit Platform specific options.
public void useJUnitPlatform(Action<? super JUnitPlatformOptions> testFrameworkConfigure)
Use this option if your tests use JUnit Jupiter/JUnit5.
JUnit Platform supports multiple test engines, which allows other testing frameworks to be built on top of it. You may need to use this option even if you are not using JUnit directly.
The supplied action configures an instance of JUnit Platform specific options
.
testFrameworkConfigure
- A closure used to configure JUnit platform options.public void useTestNG()
Configure TestNG specific options.
public void useTestNG(@DelegatesTo(TestNGOptions.class) Closure testFrameworkConfigure)
The supplied action configures an instance of TestNG specific options
.
testFrameworkConfigure
- A closure used to configure TestNG options.public void useTestNG(Action<? super TestNGOptions> testFrameworkConfigure)
The supplied action configures an instance of TestNG specific options
.
testFrameworkConfigure
- An action used to configure TestNG options.@Classpath protected FileCollection getStableClasspath()
@Internal("captured by stableClasspath") public FileCollection getClasspath()
public void setClasspath(FileCollection classpath)
@Input public boolean isScanForTestClasses()
true
the classes which match the include and exclude patterns are scanned for test classes, and any found are executed. When
false
the classes which match the include and exclude patterns are executed.public void setScanForTestClasses(boolean scanForTestClasses)
@Internal public long getForkEvery()
By default, Gradle automatically uses a separate JVM when executing tests.
0
(no limit) means to reuse the test process for all test classes. This is the default.1
means that a new test process is started for every test class. This is very expensive.N
means that a new test process is started after N
test classes.public void setForkEvery(@Nullable java.lang.Long forkEvery)
By default, Gradle automatically uses a separate JVM when executing tests, so changing this property is usually not necessary.
forkEvery
- The maximum number of test classes. Use null or 0 to specify no maximum.@Internal public int getMaxParallelForks()
By default, Gradle executes a single test class at a time.
1
means to only execute a single test class in a single test process at a time. This is the default.N
means that up to N
test processes will be started to execute test classes. This can improve test execution time by running multiple test classes in parallel.Test
tasks.public void setMaxParallelForks(int maxParallelForks)
By default, Gradle executes a single test class at a time but allows multiple Test
tasks to run in parallel.
maxParallelForks
- The maximum number of forked test processes. Use 1 to disable parallel test execution for this task.@InputFiles @SkipWhenEmpty @IgnoreEmptyDirectories @PathSensitive(RELATIVE) public FileTree getCandidateClassFiles()
public void filter(Action<TestFilter> action)
AbstractTestTask.getFilter()
.action
- configuration of the test filterpublic Property<JavaLauncher> getJavaLauncher()
@Inject protected ObjectFactory getObjectFactory()
@Inject protected JavaToolchainService getJavaToolchainService()
@Inject protected ProviderFactory getProviderFactory()
@Inject protected org.gradle.internal.actor.ActorFactory getActorFactory()
@Inject protected org.gradle.process.internal.worker.WorkerProcessFactory getProcessBuilderFactory()
@Inject protected org.gradle.internal.Factory<PatternSet> getPatternSetFactory()
@Inject protected org.gradle.process.internal.JavaForkOptionsFactory getForkOptionsFactory()
@Inject protected org.gradle.api.internal.classpath.ModuleRegistry getModuleRegistry()
@Inject protected org.gradle.internal.jvm.JavaModuleDetector getJavaModuleDetector()