public interface TestFilter
apply plugin: 'java'
test {
filter {
//specific test class, this can match 'SomeTest' class and corresponding method under any package
includeTestsMatching "SomeTest"
includeTestsMatching "SomeTest.someTestMethod*"
//specific test class
includeTestsMatching "org.gradle.SomeTest"
//specific test class and method
includeTestsMatching "org.gradle.SomeTest.someSpecificFeature"
includeTest "org.gradle.SomeTest", "someTestMethod"
//specific test method, use wildcard
includeTestsMatching "*SomeTest.someSpecificFeature"
//specific test class, wildcard for packages
includeTestsMatching "*.SomeTest"
//all classes in package, recursively
includeTestsMatching "com.gradle.tooling.*"
//all integration tests, by naming convention
includeTestsMatching "*IntegTest"
//only ui tests from integration tests, by some naming convention
includeTestsMatching "*IntegTest*ui"
}
}
| Modifier and Type | Method | Description |
|---|---|---|
TestFilter |
excludeTest(String className,
String methodName) |
Excludes a test method specified by test class name and method name.
|
TestFilter |
excludeTestsMatching(String testNamePattern) |
Appends a test name pattern to the exclusion filter.
|
Set<String> |
getExcludePatterns() |
Returns the excluded test name patterns.
|
Set<String> |
getIncludePatterns() |
Returns the included test name patterns.
|
TestFilter |
includeTest(String className,
String methodName) |
Add a test method specified by test class name and method name.
|
TestFilter |
includeTestsMatching(String testNamePattern) |
Appends a test name pattern to the inclusion filter.
|
boolean |
isFailOnNoMatchingTests() |
Returns whether the task should fail if no matching tests where found.
|
TestFilter |
setExcludePatterns(String... testNamePatterns) |
Sets the test name patterns to be excluded in the filter.
|
void |
setFailOnNoMatchingTests(boolean failOnNoMatchingTests) |
Let the test task fail if a filter configuration was provided but no test matched the given configuration.
|
TestFilter |
setIncludePatterns(String... testNamePatterns) |
Sets the test name patterns to be included in the filter.
|
TestFilter includeTestsMatching(String testNamePattern)
TestFilter.testNamePattern - test name pattern to include, can be class or method name, can contain wildcard '*'TestFilter excludeTestsMatching(String testNamePattern)
TestFilter.testNamePattern - test name pattern to exclude, can be class or method name, can contain wildcard '*'@Input Set<String> getIncludePatterns()
includeTestsMatching(String) or set via
setIncludePatterns(String...).@Input Set<String> getExcludePatterns()
excludeTestsMatching(String) or set via
setExcludePatterns(String...).TestFilter setIncludePatterns(String... testNamePatterns)
testNamePatterns - class or method name patterns to set, may contain wildcard '*'TestFilter setExcludePatterns(String... testNamePatterns)
testNamePatterns - class or method name patterns to set, may contain wildcard '*'TestFilter includeTest(String className, String methodName)
className - the class name of the test to executemethodName - the method name of the test to execute. Can be null.TestFilter excludeTest(String className, String methodName)
className - the class name of the test to excludemethodName - the method name of the test to exclude. Can be null.void setFailOnNoMatchingTests(boolean failOnNoMatchingTests)
failOnNoMatchingTests - whether a test task should fail if no test is matching the filter configuration.@Input boolean isFailOnNoMatchingTests()