Class MethodHelper

java.lang.Object
org.testng.internal.MethodHelper

public class MethodHelper extends Object
Collection of helper methods to help sort and arrange methods.
  • Field Details

  • Constructor Details

    • MethodHelper

      public MethodHelper()
  • Method Details

    • collectAndOrderMethods

      public static ITestNGMethod[] collectAndOrderMethods(List<ITestNGMethod> methods, boolean forTests, RunInfo runInfo, IAnnotationFinder finder, boolean unique, List<ITestNGMethod> outExcludedMethods, Comparator<ITestNGMethod> comparator)
      Collects and orders test or configuration methods
      Parameters:
      methods - methods to be worked on
      forTests - true for test methods, false for configuration methods
      runInfo - - RunInfo object.
      finder - annotation finder
      unique - true for unique methods, false otherwise
      outExcludedMethods - - A List of excluded ITestNGMethod methods.
      Returns:
      list of ordered methods
    • findDependedUponMethods

      protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, List<ITestNGMethod> methods)
      Finds TestNG methods that the specified TestNG method depends upon
      Parameters:
      m - TestNG method
      methods - list of methods to search for depended upon methods
      Returns:
      list of methods that match the criteria
    • findDependedUponMethods

      public static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, ITestNGMethod[] methods)
      Finds TestNG methods that the specified TestNG method depends upon
      Parameters:
      m - TestNG method
      methods - list of methods to search for depended upon methods
      Returns:
      list of methods that match the criteria
    • findMethodByName

      private static Method findMethodByName(ITestNGMethod testngMethod, String regExp)
      Finds method based on regex and TestNGMethod. If regex doesn't represent the class name, uses the TestNG method's class name.
      Parameters:
      testngMethod - TestNG method
      regExp - regex representing a method and/or related class name
    • isEnabled

      public static boolean isEnabled(Class<?> objectClass, IAnnotationFinder finder)
    • isEnabled

      public static boolean isEnabled(Method m, IAnnotationFinder finder)
    • isEnabled

      public static boolean isEnabled(ITestOrConfiguration test)
    • isAlwaysRun

      public static boolean isAlwaysRun(IConfigurationAnnotation configurationAnnotation)
    • uniqueMethodList

      public static List<ITestNGMethod> uniqueMethodList(Collection<List<ITestNGMethod>> methods)
      Extracts the unique list of ITestNGMethods.
    • topologicalSort

      private static Graph<ITestNGMethod> topologicalSort(ITestNGMethod[] methods, List<ITestNGMethod> sequentialList, List<ITestNGMethod> parallelList, Comparator<ITestNGMethod> comparator)
    • sortMethodsByInstance

      private static Map<Object,List<ITestNGMethod>> sortMethodsByInstance(ITestNGMethod[] methods)
      This method is used to create a map of test instances and their associated method(s) . Used to decrease the scope to only a methods instance when trying to find method dependencies.
      Parameters:
      methods - Methods to be sorted
      Returns:
      Map of Instances as the keys and the methods associated with the instance as the values
    • calculateMethodCanonicalName

      protected static String calculateMethodCanonicalName(ITestNGMethod m)
    • calculateMethodCanonicalName

      private static String calculateMethodCanonicalName(Method m)
    • sortMethods

      private static List<ITestNGMethod> sortMethods(boolean forTests, List<ITestNGMethod> allMethods, Comparator<ITestNGMethod> comparator)
    • getMethodsDependedUpon

      public static List<ITestNGMethod> getMethodsDependedUpon(ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator)
      Returns:
      A sorted array containing all the methods 'method' depends on
    • fixMethodsWithClass

      public static void fixMethodsWithClass(ITestNGMethod[] methods, ITestClass testCls, List<ITestNGMethod> methodList)
    • methodsToMethodInstances

      public static List<IMethodInstance> methodsToMethodInstances(List<ITestNGMethod> sl)
    • methodInstancesToMethods

      public static List<ITestNGMethod> methodInstancesToMethods(List<IMethodInstance> methodInstances)
    • dumpInvokedMethodInfoToConsole

      public static void dumpInvokedMethodInfoToConsole(ITestNGMethod[] methods, int currentVerbosity)
    • isConfigurationMethod

      private static boolean isConfigurationMethod(ITestNGMethod tm)
    • calculateMethodCanonicalName

      protected static String calculateMethodCanonicalName(Class<?> methodClass, String methodName)
    • clear

      public static void clear(Stream<Method> methods)
    • calculateTimeOut

      public static long calculateTimeOut(ITestNGMethod tm)
    • matchMethod

      private static MethodHelper.MatchResults matchMethod(ITestNGMethod[] methods, String regexp)