Package org.testng.internal
Class XmlMethodSelector
- java.lang.Object
-
- org.testng.internal.XmlMethodSelector
-
- All Implemented Interfaces:
IMethodSelector
public class XmlMethodSelector extends java.lang.Object implements IMethodSelector
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. Created on Sep 30, 2005
-
-
Field Summary
Fields Modifier and Type Field Description private IBsh
m_bsh
private java.util.List<XmlClass>
m_classes
private java.util.Map<java.lang.String,java.lang.String>
m_excludedGroups
private java.lang.String
m_expression
private java.util.Map<java.lang.String,java.lang.String>
m_includedGroups
private ListMultiMap<java.lang.String,XmlInclude>
m_includedMethods
private boolean
m_isInitialized
private java.util.Map<java.lang.String,java.lang.String>
m_logged
private java.util.List<ITestNGMethod>
m_testMethods
private static java.lang.String
QUOTED_DOLLAR
-
Constructor Summary
Constructors Constructor Description XmlMethodSelector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
assignable(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
private static void
checkMethod(java.lang.Class<?> c, java.lang.String methodName)
private static java.util.List<java.lang.String>
createQualifiedMethodNames(XmlClass xmlClass, java.util.List<java.lang.String> methods)
java.util.Map<java.lang.String,java.lang.String>
getExcludedGroups()
java.util.Map<java.lang.String,java.lang.String>
getIncludedGroups()
private boolean
hasExcludedMethods()
private boolean
hasIncludedMethods()
boolean
includeMethod(IMethodSelectorContext context, ITestNGMethod tm, boolean isTestMethod)
private boolean
includeMethodFromIncludeExclude(ITestNGMethod tm, boolean isTestMethod)
private void
init(IMethodSelectorContext context)
private static boolean
isExcluded(java.util.Collection<java.lang.String> excludedGroups, java.lang.String... groups)
private static boolean
isIncluded(java.util.Collection<java.lang.String> includedGroups, boolean noGroupsSpecified, java.lang.String... groups)
private static boolean
isMemberOf(java.util.Collection<java.lang.String> list, java.lang.String... groups)
private static void
log(java.lang.String s)
private void
logInclusion(java.lang.String including, java.lang.String type, java.lang.String name)
private static java.lang.String
makeMethodName(java.lang.String className, java.lang.String methodName)
private static java.lang.String
methodName(java.lang.String methodName)
void
setExcludedGroups(java.util.Map<java.lang.String,java.lang.String> excludedGroups)
void
setExpression(java.lang.String expression)
void
setIncludedGroups(java.util.Map<java.lang.String,java.lang.String> includedGroups)
void
setTestMethods(java.util.List<ITestNGMethod> testMethods)
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.void
setXmlClasses(java.util.List<XmlClass> classes)
private static java.util.List<java.lang.String>
toStringList(java.util.List<XmlInclude> methods)
-
-
-
Field Detail
-
QUOTED_DOLLAR
private static final java.lang.String QUOTED_DOLLAR
-
m_includedMethods
private final ListMultiMap<java.lang.String,XmlInclude> m_includedMethods
-
m_bsh
private final IBsh m_bsh
-
m_logged
private final java.util.Map<java.lang.String,java.lang.String> m_logged
-
m_includedGroups
private java.util.Map<java.lang.String,java.lang.String> m_includedGroups
-
m_excludedGroups
private java.util.Map<java.lang.String,java.lang.String> m_excludedGroups
-
m_classes
private java.util.List<XmlClass> m_classes
-
m_expression
private java.lang.String m_expression
-
m_isInitialized
private boolean m_isInitialized
-
m_testMethods
private java.util.List<ITestNGMethod> m_testMethods
-
-
Method Detail
-
includeMethod
public boolean includeMethod(IMethodSelectorContext context, ITestNGMethod tm, boolean isTestMethod)
- Specified by:
includeMethod
in interfaceIMethodSelector
- Parameters:
context
- 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
- The test methodisTestMethod
- true if this is a @Test method, false if it's a configuration method- Returns:
- true if this method should be included in the test run, false otherwise
-
includeMethodFromIncludeExclude
private boolean includeMethodFromIncludeExclude(ITestNGMethod tm, boolean isTestMethod)
-
assignable
private static boolean assignable(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
-
logInclusion
private void logInclusion(java.lang.String including, java.lang.String type, java.lang.String name)
-
hasIncludedMethods
private boolean hasIncludedMethods()
-
hasExcludedMethods
private boolean hasExcludedMethods()
-
toStringList
private static java.util.List<java.lang.String> toStringList(java.util.List<XmlInclude> methods)
-
createQualifiedMethodNames
private static java.util.List<java.lang.String> createQualifiedMethodNames(XmlClass xmlClass, java.util.List<java.lang.String> methods)
-
methodName
private static java.lang.String methodName(java.lang.String methodName)
-
makeMethodName
private static java.lang.String makeMethodName(java.lang.String className, java.lang.String methodName)
-
checkMethod
private static void checkMethod(java.lang.Class<?> c, java.lang.String methodName)
-
setXmlClasses
public void setXmlClasses(java.util.List<XmlClass> classes)
-
getExcludedGroups
public java.util.Map<java.lang.String,java.lang.String> getExcludedGroups()
- Returns:
- Returns the excludedGroups.
-
getIncludedGroups
public java.util.Map<java.lang.String,java.lang.String> getIncludedGroups()
- Returns:
- Returns the includedGroups.
-
setExcludedGroups
public void setExcludedGroups(java.util.Map<java.lang.String,java.lang.String> excludedGroups)
- Parameters:
excludedGroups
- The excludedGroups to set.
-
setIncludedGroups
public void setIncludedGroups(java.util.Map<java.lang.String,java.lang.String> includedGroups)
- Parameters:
includedGroups
- The includedGroups to set.
-
isIncluded
private static boolean isIncluded(java.util.Collection<java.lang.String> includedGroups, boolean noGroupsSpecified, java.lang.String... groups)
-
isExcluded
private static boolean isExcluded(java.util.Collection<java.lang.String> excludedGroups, java.lang.String... groups)
-
isMemberOf
private static boolean isMemberOf(java.util.Collection<java.lang.String> list, java.lang.String... groups)
- Parameters:
groups
- Array of groups on the methodlist
- Map of regexps of groups to be run
-
log
private static void log(java.lang.String s)
-
setExpression
public void setExpression(java.lang.String expression)
-
setTestMethods
public void setTestMethods(java.util.List<ITestNGMethod> testMethods)
Description copied from interface:IMethodSelector
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.- Specified by:
setTestMethods
in interfaceIMethodSelector
-
init
private void init(IMethodSelectorContext context)
-
-