Top Description Fields Constructors Methods
org.testng.internal

public Class XmlMethodSelector

extends Object
implements IMethodSelector
Class Inheritance
All Implemented Interfaces
org.testng.IMethodSelector
Imports
java.lang.reflect.Method, java.util.Arrays, .Collection, .Collections, .HashSet, .List, .Map, .Optional, .Set, java.util.regex.Matcher, .Pattern, java.util.stream.Stream, org.testng.IMethodSelector, .IMethodSelectorContext, .ITestNGMethod, org.testng.collections.ListMultiMap, .Lists, .Maps, org.testng.internal.reflect.ReflectionHelper, org.testng.xml.XmlClass, .XmlInclude, .XmlScript

This class is the default method selector used by TestNG to determine which methods need to be included and excluded based on the specification given in testng.xml.

Field Summary

Modifier and TypeField and Description
private List<XmlClass>
private Map<String, String>
private Map<String, String>
private final ListMultiMap<String, XmlInclude>
private boolean
private final Map<String, String>
private boolean
private List<ITestNGMethod>
private static final String
private ScriptMethodSelector

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
assignable(Class<?> sourceClass, Class<?> targetClass)

private static void
checkMethod(Class<?> c, String methodName)

private static List<String>
public Map<String, String>

Returns:

Returns the excludedGroups.
getExcludedGroups
()

public Map<String, String>

Returns:

Returns the includedGroups.
getIncludedGroups
()

public boolean
private boolean
private boolean
public boolean
includeMethod(IMethodSelectorContext
The selector context. The implementation of this method can invoke setHalted(true) to indicate that no other Method Selector should be invoked by TestNG after this one. Additionally, this implementation can manipulate the Map object returned by getUserData().
context
,
ITestNGMethod
The test method
tm
,
boolean
true if this is a @Test method, false if it's a configuration method
isTestMethod
)

Implements org.testng.IMethodSelector.includeMethod.

private boolean
private void
private static boolean
isExcluded(Collection<String> excludedGroups, String... groups)

private static boolean
isIncluded(Collection<String> includedGroups, boolean noGroupsSpecified, String... groups)

private static boolean
isMemberOf(Collection<String>
Map of regexps of groups to be run
list
,
String...
Array of groups on the method
groups
)

private static void
private void
logInclusion(String including, String type, String name)

private static String
makeMethodName(String className, String methodName)

private static String
methodName(String methodName)

public void
setExcludedGroups(Map<String, String>
The excludedGroups to set.
excludedGroups
)

public void
setIncludedGroups(Map<String, String>
The includedGroups to set.
includedGroups
)

public void
setOverrideIncludedMethods(boolean overrideIncludedMethods)

public void
public void
setTestMethods(List<ITestNGMethod>
The test methods
testMethods
)

Implements org.testng.IMethodSelector.setTestMethods.

Invoked when all the test methods are known so that the method selector can perform additional work, such as adding the transitive closure of all the groups being included and depended upon.
public void
private static List<String>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

m_classesback to summary
private List<XmlClass> m_classes
m_excludedGroupsback to summary
private Map<String, String> m_excludedGroups
m_includedGroupsback to summary
private Map<String, String> m_includedGroups
m_includedMethodsback to summary
private final ListMultiMap<String, XmlInclude> m_includedMethods
m_isInitializedback to summary
private boolean m_isInitialized
m_loggedback to summary
private final Map<String, String> m_logged
m_overrideIncludedMethodsback to summary
private boolean m_overrideIncludedMethods
m_testMethodsback to summary
private List<ITestNGMethod> m_testMethods
QUOTED_DOLLARback to summary
private static final String QUOTED_DOLLAR
scriptSelectorback to summary
private ScriptMethodSelector scriptSelector

Constructor Detail

XmlMethodSelectorback to summary
public XmlMethodSelector()

Method Detail

assignableback to summary
private static boolean assignable(Class<?> sourceClass, Class<?> targetClass)
checkMethodback to summary
private static void checkMethod(Class<?> c, String methodName)
createQualifiedMethodNamesback to summary
private static List<String> createQualifiedMethodNames(XmlClass xmlClass, List<String> methods)
getExcludedGroupsback to summary
public Map<String, String> getExcludedGroups()
Returns:Map<String, String>

Returns the excludedGroups.

getIncludedGroupsback to summary
public Map<String, String> getIncludedGroups()
Returns:Map<String, String>

Returns the includedGroups.

getOverrideIncludedMethodsback to summary
public boolean getOverrideIncludedMethods()
hasExcludedMethodsback to summary
private boolean hasExcludedMethods()
hasIncludedMethodsback to summary
private boolean hasIncludedMethods()
includeMethodback to summary
public boolean includeMethod(IMethodSelectorContext context, ITestNGMethod tm, boolean isTestMethod)

Implements org.testng.IMethodSelector.includeMethod.

Parameters
context:IMethodSelectorContext

Doc from org.testng.IMethodSelector.includeMethod.

The selector context. The implementation of this method can invoke setHalted(true) to indicate that no other Method Selector should be invoked by TestNG after this one. Additionally, this implementation can manipulate the Map object returned by getUserData().

tm:ITestNGMethod

Doc from org.testng.IMethodSelector.includeMethod.

The test method

isTestMethod:boolean

Doc from org.testng.IMethodSelector.includeMethod.

true if this is a @Test method, false if it's a configuration method

Returns:boolean

Doc from org.testng.IMethodSelector.includeMethod.

true if this method should be included in the test run, false otherwise

Annotations
@Override
includeMethodFromIncludeExcludeback to summary
private boolean includeMethodFromIncludeExclude(ITestNGMethod tm, boolean isTestMethod)
initback to summary
private void init(IMethodSelectorContext context)
isExcludedback to summary
private static boolean isExcluded(Collection<String> excludedGroups, String... groups)
isIncludedback to summary
private static boolean isIncluded(Collection<String> includedGroups, boolean noGroupsSpecified, String... groups)
isMemberOfback to summary
private static boolean isMemberOf(Collection<String> list, String... groups)
Parameters
list:Collection<String>

Map of regexps of groups to be run

groups:String[]

Array of groups on the method

logback to summary
private static void log(String s)
logInclusionback to summary
private void logInclusion(String including, String type, String name)
makeMethodNameback to summary
private static String makeMethodName(String className, String methodName)
methodNameback to summary
private static String methodName(String methodName)
setExcludedGroupsback to summary
public void setExcludedGroups(Map<String, String> excludedGroups)
Parameters
excludedGroups:Map<String, String>

The excludedGroups to set.

setIncludedGroupsback to summary
public void setIncludedGroups(Map<String, String> includedGroups)
Parameters
includedGroups:Map<String, String>

The includedGroups to set.

setOverrideIncludedMethodsback to summary
public void setOverrideIncludedMethods(boolean overrideIncludedMethods)
setScriptback to summary
public void setScript(XmlScript script)
setTestMethodsback to summary
public void setTestMethods(List<ITestNGMethod> testMethods)

Implements org.testng.IMethodSelector.setTestMethods.

Doc from org.testng.IMethodSelector.setTestMethods.

Invoked when all the test methods are known so that the method selector can perform additional work, such as adding the transitive closure of all the groups being included and depended upon.

Parameters
testMethods:List<ITestNGMethod>

The test methods

Annotations
@Override
setXmlClassesback to summary
public void setXmlClasses(List<XmlClass> classes)
toStringListback to summary
private static List<String> toStringList(List<XmlInclude> methods)