Interface TestFilter
Allows filtering tests for execution. Some examples:
apply plugin: 'java'
test {
filter {
//specific test method
includeTestsMatching "org.gradle.SomeTest.someSpecificFeature"
//specific test method, use wildcard for packages
includeTestsMatching "*SomeTest.someSpecificFeature"
//specific test class
includeTestsMatching "org.gradle.SomeTest"
//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"
//specific test class and test method
includeTest "org.gradle.SomeTest", "someTestMethod"
}
}
- Since:
- 1.10
-
Method Summary
Modifier and TypeMethodDescriptionReturns the included test name patterns.includeTest(String className, String methodName) Add a test method specified by test class name and method name.includeTestsMatching(String testNamePattern) Appends a test name pattern to the filter.booleanReturns whether the task should fail if no matching tests where found.voidsetFailOnNoMatchingTests(boolean failOnNoMatchingTests) Let the test task fail if a filter configuration was provided but no test matched the given configuration.setIncludePatterns(String... testNamePatterns) Sets the test name patterns to be included in the filter.
-
Method Details
-
includeTestsMatching
Appends a test name pattern to the filter. Wildcard '*' is supported, either test method name or class name is supported. Examples of test names: "com.foo.FooTest.someMethod", "com.foo.FooTest", "*FooTest*", "com.foo*". See examples in the docs forTestFilter.- Parameters:
testNamePattern- test name pattern to include, can be class or method name, can contain wildcard '*'- Returns:
- this filter object
-
getIncludePatterns
Returns the included test name patterns. They can be class or method names and may contain wildcard '*'. Test name patterns can be appended viaincludeTestsMatching(String)or set viasetIncludePatterns(String...).- Returns:
- included test name patterns
-
setIncludePatterns
Sets the test name patterns to be included in the filter. Wildcard '*' is supported. Replaces any existing test name patterns.- Parameters:
testNamePatterns- class or method name patterns to set, may contain wildcard '*'- Returns:
- this filter object
-
includeTest
Add a test method specified by test class name and method name.- Parameters:
className- the class name of the test to executemethodName- the method name of the test to execute. Can be null.- Returns:
- this filter object
-
setFailOnNoMatchingTests
void setFailOnNoMatchingTests(boolean failOnNoMatchingTests) Let the test task fail if a filter configuration was provided but no test matched the given configuration.- Parameters:
failOnNoMatchingTests- whether a test task should fail if no test is matching the filter configuration.
-
isFailOnNoMatchingTests
Returns whether the task should fail if no matching tests where found. The default is true.
-