Package org.testng.internal
Class MethodHelper
java.lang.Object
org.testng.internal.MethodHelper
Collection of helper methods to help sort and arrange methods.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static StringcalculateMethodCanonicalName(Class<?> methodClass, String methodName) private static Stringprotected static Stringstatic longstatic voidstatic 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 methodsstatic voiddumpInvokedMethodInfoToConsole(ITestNGMethod[] methods, int currentVerbosity) private static Pair<String, Predicate<ITestNGMethod>> protected static ITestNGMethod[]findDependedUponMethods(ITestNGMethod m, List<ITestNGMethod> methods) Finds TestNG methods that the specified TestNG method depends uponstatic ITestNGMethod[]findDependedUponMethods(ITestNGMethod m, ITestNGMethod[] incoming) Finds TestNG methods that the specified TestNG method depends uponprivate static MethodfindMethodByName(ITestNGMethod testngMethod, String regExp) Finds method based on regex and TestNGMethod.static voidfixMethodsWithClass(ITestNGMethod[] methods, ITestClass testCls, List<ITestNGMethod> methodList) static List<ITestNGMethod> getMethodsDependedUpon(ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator) static booleanisAlwaysRun(IConfigurationAnnotation configurationAnnotation) private static booleanstatic booleanisEnabled(Class<?> objectClass, IAnnotationFinder finder) static booleanisEnabled(Method m, IAnnotationFinder finder) static booleanprivate static MethodHelper.MatchResultsmatchMethod(ITestNGMethod[] methods, String regexp) static List<ITestNGMethod> methodInstancesToMethods(List<IMethodInstance> methodInstances) static List<IMethodInstance> private static List<ITestNGMethod> sortMethods(boolean forTests, List<ITestNGMethod> allMethods, Comparator<ITestNGMethod> comparator) 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) .private static Graph<ITestNGMethod> topologicalSort(ITestNGMethod[] methods, List<ITestNGMethod> sequentialList, List<ITestNGMethod> parallelList, Comparator<ITestNGMethod> comparator) static List<ITestNGMethod> uniqueMethodList(Collection<List<ITestNGMethod>> methods) Extracts the unique list ofITestNGMethods.
-
Field Details
-
GRAPH_CACHE
-
CANONICAL_NAME_CACHE
-
MATCH_CACHE
-
-
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 onforTests- true for test methods, false for configuration methodsrunInfo- -RunInfoobject.finder- annotation finderunique- true for unique methods, false otherwiseoutExcludedMethods- - A List of excludedITestNGMethodmethods.- Returns:
- an array 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 methodmethods- list of methods to search for depended upon methods- Returns:
- an array of methods that match the criteria
-
filterToUse
-
findDependedUponMethods
Finds TestNG methods that the specified TestNG method depends upon- Parameters:
m- TestNG methodincoming- list of methods to search for depended upon methods- Returns:
- an array of methods that match the criteria
-
findMethodByName
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 methodregExp- regex representing a method and/or related class name
-
isEnabled
-
isEnabled
-
isEnabled
-
isAlwaysRun
-
uniqueMethodList
Extracts the unique list ofITestNGMethods. -
topologicalSort
private static Graph<ITestNGMethod> topologicalSort(ITestNGMethod[] methods, List<ITestNGMethod> sequentialList, List<ITestNGMethod> parallelList, Comparator<ITestNGMethod> comparator) -
sortMethodsByInstance
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
-
calculateMethodCanonicalName
-
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
-
methodInstancesToMethods
-
dumpInvokedMethodInfoToConsole
-
isConfigurationMethod
-
calculateMethodCanonicalName
-
clear
-
calculateTimeOut
-
matchMethod
-