Class XmlMethodSelector

java.lang.Object
org.testng.internal.XmlMethodSelector
All Implemented Interfaces:
IMethodSelector

public class XmlMethodSelector extends 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.
  • Field Details

  • Constructor Details

    • XmlMethodSelector

      public XmlMethodSelector()
  • Method Details

    • includeMethod

      public boolean includeMethod(IMethodSelectorContext context, ITestNGMethod tm, boolean isTestMethod)
      Specified by:
      includeMethod in interface IMethodSelector
      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 method
      isTestMethod - 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(Class<?> sourceClass, Class<?> targetClass)
    • logInclusion

      private void logInclusion(String including, String type, String name)
    • hasIncludedMethods

      private boolean hasIncludedMethods()
    • hasExcludedMethods

      private boolean hasExcludedMethods()
    • toStringList

      private static List<String> toStringList(List<XmlInclude> methods)
    • createQualifiedMethodNames

      private static List<String> createQualifiedMethodNames(XmlClass xmlClass, List<String> methods)
    • methodName

      private static String methodName(String methodName)
    • makeMethodName

      private static String makeMethodName(String className, String methodName)
    • checkMethod

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

      public void setXmlClasses(List<XmlClass> classes)
    • getExcludedGroups

      public Map<String,String> getExcludedGroups()
      Returns:
      Returns the excludedGroups.
    • getIncludedGroups

      public Map<String,String> getIncludedGroups()
      Returns:
      Returns the includedGroups.
    • setExcludedGroups

      public void setExcludedGroups(Map<String,String> excludedGroups)
      Parameters:
      excludedGroups - The excludedGroups to set.
    • setIncludedGroups

      public void setIncludedGroups(Map<String,String> includedGroups)
      Parameters:
      includedGroups - The includedGroups to set.
    • isIncluded

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

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

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

      private static void log(String s)
    • setScript

      public void setScript(XmlScript script)
    • setTestMethods

      public void setTestMethods(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 interface IMethodSelector
      Parameters:
      testMethods - The test methods
    • getOverrideIncludedMethods

      public boolean getOverrideIncludedMethods()
    • setOverrideIncludedMethods

      public void setOverrideIncludedMethods(boolean overrideIncludedMethods)
    • init

      private void init(IMethodSelectorContext context)