Test (Gradle API 8.14) (original) (raw)
Method Details
getWorkingDir
Returns the working directory for the process. Defaults to the project directory.
Specified by:[getWorkingDir](../../../process/ProcessForkOptions.html#getWorkingDir%28%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Returns:
The working directory. Never returns null.
setWorkingDir
public void setWorkingDir(File dir)
Sets the working directory for the process.
Specified by:[setWorkingDir](../../../process/ProcessForkOptions.html#setWorkingDir%28java.io.File%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:dir
- The working directory. Must not be null.
setWorkingDir
public void setWorkingDir(Object dir)
Sets the working directory for the process. The supplied argument is evaluated as per Project.file(Object).
Specified by:[setWorkingDir](../../../process/ProcessForkOptions.html#setWorkingDir%28java.lang.Object%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:dir
- The working directory. Must not be null.
workingDir
Sets the working directory for the process. The supplied argument is evaluated as per Project.file(Object).
Specified by:[workingDir](../../../process/ProcessForkOptions.html#workingDir%28java.lang.Object%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
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 JavaLauncher specified by getJavaLauncher(), or the executable specified by getExecutable() if the JavaLauncher
is not present.
Since:
3.3
getExecutable
Returns the name of the executable to use.
Specified by:[getExecutable](../../../process/ProcessForkOptions.html#getExecutable%28%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Returns:
The executable.
executable
public Test executable(Object executable)
Sets the name of the executable to use.
Specified by:[executable](../../../process/ProcessForkOptions.html#executable%28java.lang.Object%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:executable
- The executable. Must not be null.
Returns:
this
setExecutable
public void setExecutable(String executable)
Sets the name of the executable to use.
Specified by:[setExecutable](../../../process/ProcessForkOptions.html#setExecutable%28java.lang.String%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:executable
- The executable. Must not be null.
setExecutable
public void setExecutable(Object executable)
Sets the name of the executable to use.
Specified by:[setExecutable](../../../process/ProcessForkOptions.html#setExecutable%28java.lang.Object%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:executable
- The executable. Must not be null.
getSystemProperties
Returns the system properties which will be used for the process.
Specified by:[getSystemProperties](../../../process/JavaForkOptions.html#getSystemProperties%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The system properties. Returns an empty map when there are no system properties.
setSystemProperties
public void setSystemProperties(Map<String,?> properties)
Sets the system properties to use for the process.
Specified by:[setSystemProperties](../../../process/JavaForkOptions.html#setSystemProperties%28java.util.Map%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:properties
- The system properties. Must not be null.
systemProperties
public Test systemProperties(Map<String,?> properties)
Adds some system properties to use for the process.
Specified by:[systemProperties](../../../process/JavaForkOptions.html#systemProperties%28java.util.Map%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:properties
- The system properties. Must not be null.
Returns:
this
systemProperty
Adds a system property to use for the process.
Specified by:[systemProperty](../../../process/JavaForkOptions.html#systemProperty%28java.lang.String,java.lang.Object%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
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](../../../process/JavaForkOptions.html#getBootstrapClasspath%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The bootstrap classpath. Never returns null.
setBootstrapClasspath
public void setBootstrapClasspath(FileCollection classpath)
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](../../../process/JavaForkOptions.html#setBootstrapClasspath%28org.gradle.api.file.FileCollection%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:classpath
- The classpath. Must not be null. Can be empty.
bootstrapClasspath
public Test bootstrapClasspath(Object... classpath)
Adds the given values to the end of the bootstrap classpath for the process.
Specified by:[bootstrapClasspath](../../../process/JavaForkOptions.html#bootstrapClasspath%28java.lang.Object...%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:classpath
- The classpath.
Returns:
this
getMinHeapSize
public String getMinHeapSize()
Returns the minimum heap size for the process, if any.
Specified by:[getMinHeapSize](../../../process/JavaForkOptions.html#getMinHeapSize%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The minimum heap size. Returns null if the default minimum heap size should be used.
getDefaultCharacterEncoding
public String getDefaultCharacterEncoding()
Returns the default character encoding to use.
Specified by:[getDefaultCharacterEncoding](../../../process/JavaForkOptions.html#getDefaultCharacterEncoding%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The default character encoding. Returns null if the default character encoding of this JVM should be used.
setDefaultCharacterEncoding
public void setDefaultCharacterEncoding(String defaultCharacterEncoding)
Sets the default character encoding to use. Note: Many JVM implementations support the setting of this attribute via system property on startup (namely, the 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().
Specified by:[setDefaultCharacterEncoding](../../../process/JavaForkOptions.html#setDefaultCharacterEncoding%28java.lang.String%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:defaultCharacterEncoding
- The default character encoding. Use null to use this JVM's default charset
setMinHeapSize
public void setMinHeapSize(String heapSize)
Sets the minimum heap size for the process. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
Specified by:[setMinHeapSize](../../../process/JavaForkOptions.html#setMinHeapSize%28java.lang.String%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:heapSize
- The minimum heap size. Use null for the default minimum heap size.
getMaxHeapSize
public String getMaxHeapSize()
Returns the maximum heap size for the process, if any.
Specified by:[getMaxHeapSize](../../../process/JavaForkOptions.html#getMaxHeapSize%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The maximum heap size. Returns null if the default maximum heap size should be used.
setMaxHeapSize
public void setMaxHeapSize(String heapSize)
Sets the maximum heap size for the process. Supports the units megabytes (e.g. "512m") and gigabytes (e.g. "1g").
Specified by:[setMaxHeapSize](../../../process/JavaForkOptions.html#setMaxHeapSize%28java.lang.String%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
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](../../../process/JavaForkOptions.html#getJvmArgs%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The immutable list of arguments. Returns an empty list if there are no arguments.
getJvmArgumentProviders
Command line argument providers for the java process to fork.
Specified by:[getJvmArgumentProviders](../../../process/JavaForkOptions.html#getJvmArgumentProviders%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
setJvmArgs
public void setJvmArgs(List<String> arguments)
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](../../../process/JavaForkOptions.html#setJvmArgs%28java.util.List%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:arguments
- The arguments. Must not be null.
setJvmArgs
public void setJvmArgs(Iterable<?> arguments)
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](../../../process/JavaForkOptions.html#setJvmArgs%28java.lang.Iterable%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:arguments
- The arguments. Must not be null.
jvmArgs
Adds some arguments to use to launch the JVM for the process.
Specified by:[jvmArgs](../../../process/JavaForkOptions.html#jvmArgs%28java.lang.Iterable%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
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](../../../process/JavaForkOptions.html#jvmArgs%28java.lang.Object...%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:arguments
- The arguments.
Returns:
this
getEnableAssertions
public boolean getEnableAssertions()
Returns true if assertions are enabled for the process.
Specified by:[getEnableAssertions](../../../process/JavaForkOptions.html#getEnableAssertions%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
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](../../../process/JavaForkOptions.html#setEnableAssertions%28boolean%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:enabled
- true to enable assertions, false to disable.
getDebug
public boolean getDebug()
Determines whether debugging is enabled for the test process. When enabled — 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 forgetForkEvery().
Since Gradle 5.6, you can configure the port and other Java debug properties viaJavaForkOptions.debugOptions(Action).
Specified by:[getDebug](../../../process/JavaForkOptions.html#getDebug%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
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.
The debug properties (e.g. the port number) can be configured in JavaForkOptions.debugOptions(Action).
Specified by:[setDebug](../../../process/JavaForkOptions.html#setDebug%28boolean%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:enabled
- true to enable debugging, false to disable.
getDebugOptions
Returns the Java Debug Wire Protocol properties for the process. If enabled then the -agentlib:jdwp=...
will be appended to the JVM arguments with the configuration from the parameter.
Specified by:[getDebugOptions](../../../process/JavaForkOptions.html#getDebugOptions%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
debugOptions
Configures Java Debug Wire Protocol properties for the process. If JavaForkOptions.setDebug(boolean) is enabled then the -agentlib:jdwp=...
will be appended to the JVM arguments with the configuration from the parameter.
Specified by:[debugOptions](../../../process/JavaForkOptions.html#debugOptions%28org.gradle.api.Action%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:action
- the Java debug configuration
setFailFast
public void setFailFast(boolean failFast)
Enables fail fast behavior causing the task to fail on the first failed test.
getFailFast
public boolean getFailFast()
Indicates if this task will fail on the first failed test
Returns:
whether this task will fail on the first failed test
getDryRun
Indicates if this task will skip individual test execution.
For JUnit 4 and 5, this will report tests that would have executed as skipped. For TestNG, this will report tests that would have executed as passed.
Only versions of TestNG which support native dry-running are supported, i.e. TestNG 6.14 or later.
Returns:
property for whether this task will skip individual test execution
Since:
8.3
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](../../../process/JavaForkOptions.html#getAllJvmArgs%28%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Returns:
The immutable list of arguments. Returns an empty list if there are no arguments.
setAllJvmArgs
public void setAllJvmArgs(List<String> arguments)
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](../../../process/JavaForkOptions.html#setAllJvmArgs%28java.util.List%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:arguments
- The arguments. Must not be null.
setAllJvmArgs
public void setAllJvmArgs(Iterable<?> arguments)
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](../../../process/JavaForkOptions.html#setAllJvmArgs%28java.lang.Iterable%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
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](../../../process/ProcessForkOptions.html#getEnvironment%28%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Returns:
The environment. Returns an empty map when there are no environment variables.
environment
public Test environment(Map<String,?> environmentVariables)
Adds some environment variables to the environment for this process.
Specified by:[environment](../../../process/ProcessForkOptions.html#environment%28java.util.Map%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
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](../../../process/ProcessForkOptions.html#environment%28java.lang.String,java.lang.Object%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:name
- The name of the variable.value
- The value for the variable. Must not be null.
Returns:
this
setEnvironment
public void setEnvironment(Map<String,?> environmentVariables)
Sets the environment variable to use for the process.
Specified by:[setEnvironment](../../../process/ProcessForkOptions.html#setEnvironment%28java.util.Map%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:environmentVariables
- The environment variables. Must not be null.
copyTo
Copies these options to the given target options.
Specified by:[copyTo](../../../process/ProcessForkOptions.html#copyTo%28org.gradle.process.ProcessForkOptions%29)
in interface [ProcessForkOptions](../../../process/ProcessForkOptions.html "interface in org.gradle.process")
Parameters:target
- The target options
Returns:
this
copyTo
Copies these options to the given options.
Specified by:[copyTo](../../../process/JavaForkOptions.html#copyTo%28org.gradle.process.JavaForkOptions%29)
in interface [JavaForkOptions](../../../process/JavaForkOptions.html "interface in org.gradle.process")
Parameters:target
- The target options.
Returns:
this
getModularity
Returns the module path handling of this test task.
Since:
6.4
createTestExecutionSpec
protected org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec createTestExecutionSpec()
Creates test execution specification. For internal use only.
Specified by:[createTestExecutionSpec](AbstractTestTask.html#createTestExecutionSpec%28%29)
in class [AbstractTestTask](AbstractTestTask.html "class in org.gradle.api.tasks.testing")
Since:
4.4
executeTests
public void executeTests()
Overrides:[executeTests](AbstractTestTask.html#executeTests%28%29)
in class [AbstractTestTask](AbstractTestTask.html "class in org.gradle.api.tasks.testing")
createTestExecuter
protected org.gradle.api.internal.tasks.testing.TestExecuter<org.gradle.api.internal.tasks.testing.JvmTestExecutionSpec> createTestExecuter()
Creates test executer. For internal use only.
Specified by:[createTestExecuter](AbstractTestTask.html#createTestExecuter%28%29)
in class [AbstractTestTask](AbstractTestTask.html "class in org.gradle.api.tasks.testing")
getNoMatchingTestErrorReasons
protected List<String> getNoMatchingTestErrorReasons()
Returns the reasons for no matching test error.
Overrides:[getNoMatchingTestErrorReasons](AbstractTestTask.html#getNoMatchingTestErrorReasons%28%29)
in class [AbstractTestTask](AbstractTestTask.html "class in org.gradle.api.tasks.testing")
include
Adds include patterns for the files in the test classes directory (e.g. '**/*Test.class')).
Specified by:[include](../util/PatternFilterable.html#include%28java.lang.String...%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:includes
- a vararg list of include patterns
Returns:
this
See Also:
- setIncludes(Iterable)
include
Adds include patterns for the files in the test classes directory (e.g. '**/*Test.class')).
Specified by:[include](../util/PatternFilterable.html#include%28java.lang.Iterable%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:includes
- a Iterable providing more include patterns
Returns:
this
See Also:
- setIncludes(Iterable)
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](../util/PatternFilterable.html#include%28org.gradle.api.specs.Spec%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:includeSpec
- the spec to add
Returns:
this
See Also:
- Pattern Format
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](../util/PatternFilterable.html#include%28groovy.lang.Closure%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:includeSpec
- the spec to add
Returns:
this
See Also:
- Pattern Format
exclude
Adds exclude patterns for the files in the test classes directory (e.g. '**/*Test.class')).
Specified by:[exclude](../util/PatternFilterable.html#exclude%28java.lang.String...%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:excludes
- a vararg list of exclude patterns
Returns:
this
See Also:
- setExcludes(Iterable)
exclude
Adds exclude patterns for the files in the test classes directory (e.g. '**/*Test.class')).
Specified by:[exclude](../util/PatternFilterable.html#exclude%28java.lang.Iterable%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:excludes
- a Iterable providing new exclude patterns
Returns:
this
See Also:
- setExcludes(Iterable)
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](../util/PatternFilterable.html#exclude%28org.gradle.api.specs.Spec%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:excludeSpec
- the spec to add
Returns:
this
See Also:
- Pattern Format
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](../util/PatternFilterable.html#exclude%28groovy.lang.Closure%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:excludeSpec
- the spec to add
Returns:
this
See Also:
- FileTreeElement
setTestNameIncludePatterns
public Test setTestNameIncludePatterns(List<String> 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 TestFilter
Overrides:[setTestNameIncludePatterns](AbstractTestTask.html#setTestNameIncludePatterns%28java.util.List%29)
in class [AbstractTestTask](AbstractTestTask.html "class in org.gradle.api.tasks.testing")
getTestClassesDirs
Returns the directories for the compiled test sources.
Returns:
All test class directories to be used.
Since:
4.0
setTestClassesDirs
public void setTestClassesDirs(FileCollection testClassesDirs)
Sets the directories to scan for compiled test sources. Typically, this would be configured to use the output of a source set:
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
}
Parameters:testClassesDirs
- All test class directories to be used.
Since:
4.0
getIncludes
Returns the include patterns for test execution.
Specified by:[getIncludes](../util/PatternFilterable.html#getIncludes%28%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Returns:
The include patterns. Returns an empty set when there are no include patterns.
See Also:
- include(String...)
setIncludes
Sets the include patterns for test execution.
Specified by:[setIncludes](../util/PatternFilterable.html#setIncludes%28java.lang.Iterable%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:includes
- The patterns list
Returns:
this
See Also:
- include(String...)
getExcludes
Returns the exclude patterns for test execution.
Specified by:[getExcludes](../util/PatternFilterable.html#getExcludes%28%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Returns:
The exclude patterns. Returns an empty set when there are no exclude patterns.
See Also:
- exclude(String...)
setExcludes
Sets the exclude patterns for test execution.
Specified by:[setExcludes](../util/PatternFilterable.html#setExcludes%28java.lang.Iterable%29)
in interface [PatternFilterable](../util/PatternFilterable.html "interface in org.gradle.api.tasks.util")
Parameters:excludes
- The patterns list
Returns:
this
See Also:
- exclude(String...)
getTestFrameworkProperty
public Property<org.gradle.api.internal.tasks.testing.TestFramework> getTestFrameworkProperty()
Returns the configured TestFramework
.
Since:
7.3
getTestFramework
@Internal public org.gradle.api.internal.tasks.testing.TestFramework getTestFramework()
testFramework
public org.gradle.api.internal.tasks.testing.TestFramework testFramework(@Nullable Closure testFrameworkConfigure)
getOptions
Returns test framework specific options. Make sure to call useJUnit(), useJUnitPlatform() or useTestNG() before using this method.
Returns:
The test framework options.
options
Configures test framework specific options.
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.
Returns:
The test framework options.
options
Configures test framework specific options.
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.
Returns:
The test framework options.
Since:
3.5
useJUnit
public void useJUnit()
Specifies that JUnit4 should be used to discover and execute the tests.
See Also:
- Configure JUnit4 specific options.
useJUnit
Specifies that JUnit4 should be used to discover and execute the tests with additional configuration.
The supplied action configures an instance of JUnit4 specific options.
Parameters:testFrameworkConfigure
- A closure used to configure JUnit4 options.
useJUnit
public void useJUnit(Action<? super JUnitOptions> testFrameworkConfigure)
Specifies that JUnit4 should be used to discover and execute the tests with additional configuration.
The supplied action configures an instance of JUnit4 specific options.
Parameters:testFrameworkConfigure
- An action used to configure JUnit4 options.
Since:
3.5
useJUnitPlatform
public void useJUnitPlatform()
Specifies that JUnit Platform should be used to discover and execute the tests.
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.
Since:
4.6
See Also:
- Configure JUnit Platform specific options.
useJUnitPlatform
Specifies that JUnit Platform should be used to discover and execute the tests with additional configuration.
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.
Parameters:testFrameworkConfigure
- A closure used to configure JUnit platform options.
Since:
4.6
useTestNG
public void useTestNG()
Specifies that TestNG should be used to discover and execute the tests.
See Also:
- Configure TestNG specific options.
useTestNG
Specifies that TestNG should be used to discover and execute the tests with additional configuration.
The supplied action configures an instance of TestNG specific options.
Parameters:testFrameworkConfigure
- A closure used to configure TestNG options.
useTestNG
Specifies that TestNG should be used to discover and execute the tests with additional configuration.
The supplied action configures an instance of TestNG specific options.
Parameters:testFrameworkConfigure
- An action used to configure TestNG options.
Since:
3.5
getStableClasspath
Returns the classpath to use to execute the tests.
Since:
6.6
getClasspath
Returns the classpath to use to execute the tests.
setClasspath
isScanForTestClasses
@Input public boolean isScanForTestClasses()
Specifies whether test classes should be detected. When true
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.
By default, Gradle automatically uses a separate JVM when executing tests.
- A value of
0
(no limit) means to reuse the test process for all test classes. This is the default. - A value of
1
means that a new test process is started for every test class. This is very expensive. - A value of
N
means that a new test process is started afterN
test classes.
This property can have a large impact on performance due to the cost of stopping and starting each test process. It is unusual for this property to be changed from the default.
Returns:
The maximum number of test classes to execute in a test process. Returns 0 when there is no maximum. setForkEvery
public void setForkEvery(long forkEvery)
Sets the maximum number of test classes to execute in a forked test process.
By default, Gradle automatically uses a separate JVM when executing tests, so changing this property is usually not necessary.
Parameters:forkEvery
- The maximum number of test classes. Use 0 to specify no maximum.
Since:
8.1
setForkEvery
Sets the maximum number of test classes to execute in a forked test process.
By default, Gradle automatically uses a separate JVM when executing tests, so changing this property is usually not necessary.
Parameters:forkEvery
- The maximum number of test classes. Use null or 0 to specify no maximum.
getMaxParallelForks
@Internal public int getMaxParallelForks()
Returns the maximum number of test processes to start in parallel.
By default, Gradle executes a single test class at a time.
- A value of
1
means to only execute a single test class in a single test process at a time. This is the default. - A value of
N
means that up toN
test processes will be started to execute test classes. This can improve test execution time by running multiple test classes in parallel.
This property cannot exceed the value of max-workers for the current build. Gradle will also limit the number of started test processes across all Test tasks.
Returns:
The maximum number of forked test processes. setMaxParallelForks
public void setMaxParallelForks(int maxParallelForks)
Sets the maximum number of test processes to start in parallel.
By default, Gradle executes a single test class at a time but allows multiple Test tasks to run in parallel.
Parameters:maxParallelForks
- The maximum number of forked test processes. Use 1 to disable parallel test execution for this task.
getCandidateClassFiles
Returns the classes files to scan for test classes.
Returns:
The candidate class files.
filter
Parameters:action
- configuration of the test filter
Since:
1.10
getJavaLauncher
Configures the java executable to be used to run the tests.
Since:
6.7
getObjectFactory
getPropertyFactory
@Injectprotected org.gradle.api.internal.provider.PropertyFactory getPropertyFactory()
getJavaToolchainService
getProviderFactory
getActorFactory
@Injectprotected org.gradle.internal.actor.ActorFactory getActorFactory()
getProcessBuilderFactory
@Injectprotected org.gradle.process.internal.worker.WorkerProcessFactory getProcessBuilderFactory()
getPatternSetFactory
@Injectprotected org.gradle.api.tasks.util.internal.PatternSetFactory getPatternSetFactory()
getForkOptionsFactory
@Injectprotected org.gradle.process.internal.JavaForkOptionsFactory getForkOptionsFactory()
getModuleRegistry
@Injectprotected org.gradle.api.internal.classpath.ModuleRegistry getModuleRegistry()
getJavaModuleDetector
@Injectprotected org.gradle.internal.jvm.JavaModuleDetector getJavaModuleDetector()