public class PatternTestSelector extends Object implements TestSelector
TestDescription
will match if this selector's class-part is a substring of the TestDescription
's full class-name, or if this selector's class-name, when interpreted as a
java.util.regex regular-expression, matches the TestDescription
's full class-name.
(The same rules apply for the method-name as well. If this selector's class-part or method-part are null, all class-names or method-names will match.)
Modifier and Type | Method and Description |
---|---|
static TestSelector |
buildFromSelectorString(String rawSelectorString)
Build a
PatternTestSelector from the given String. |
boolean |
containsClassPath(String classPath) |
String |
getExplanation() |
String |
getRawSelector() |
boolean |
isInclusive() |
boolean |
isMatchAnyClass() |
boolean |
isMatchAnyMethod() |
boolean |
matches(TestDescription description)
Whether this
TestSelector matches the given TestDescription . |
boolean |
matchesClassName(String className) |
public static TestSelector buildFromSelectorString(String rawSelectorString)
PatternTestSelector
from the given String. Selector strings should be of the
form "[is-exclusive][class-part]#[method-part]". If "[is-exclusive]" is a "!" then this
selector will exclude tests, otherwise it will include tests.
If the class-part (or method-part) are omitted, then all classes or methods will match. Consequently "#" means "include everything" and "!#" means "exclude everything".
If the selector string doesn't contain a "#" at all, it is interpreted as a class-part.
rawSelectorString
- An unparsed selector string.public String getRawSelector()
getRawSelector
in interface TestSelector
public String getExplanation()
getExplanation
in interface TestSelector
public boolean isInclusive()
isInclusive
in interface TestSelector
public boolean isMatchAnyClass()
isMatchAnyClass
in interface TestSelector
public boolean isMatchAnyMethod()
isMatchAnyMethod
in interface TestSelector
public boolean matches(TestDescription description)
TestSelector
TestSelector
matches the given TestDescription
. A class or method
name being null in the TestDescription
means that it will match anything.matches
in interface TestSelector
description
- the TestDescription
to matchTestDescription
public boolean matchesClassName(String className)
matchesClassName
in interface TestSelector
public boolean containsClassPath(String classPath)
containsClassPath
in interface TestSelector