Package org.testng.internal
Class MethodHelper
- java.lang.Object
-
- org.testng.internal.MethodHelper
-
public class MethodHelper extends java.lang.ObjectCollection of helper methods to help sort and arrange methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMethodHelper.MatchResults
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.reflect.Method,java.lang.String>CANONICAL_NAME_CACHEprivate static java.util.Map<ITestNGMethod[],Graph<ITestNGMethod>>GRAPH_CACHEprivate static java.util.Map<Pair<java.lang.String,java.lang.String>,java.lang.Boolean>MATCH_CACHE
-
Constructor Summary
Constructors Constructor Description MethodHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringcalculateMethodCanonicalName(java.lang.Class<?> methodClass, java.lang.String methodName)private static java.lang.StringcalculateMethodCanonicalName(java.lang.reflect.Method m)protected static java.lang.StringcalculateMethodCanonicalName(ITestNGMethod m)protected static longcalculateTimeOut(ITestNGMethod tm)static ITestNGMethod[]collectAndOrderMethods(java.util.List<ITestNGMethod> methods, boolean forTests, RunInfo runInfo, IAnnotationFinder finder, boolean unique, java.util.List<ITestNGMethod> outExcludedMethods, java.util.Comparator<ITestNGMethod> comparator)Collects and orders test or configuration methodsstatic voiddumpInvokedMethodsInfoToConsole(java.util.Collection<IInvokedMethod> iInvokedMethods, int currentVerbosity)protected static ITestNGMethod[]findDependedUponMethods(ITestNGMethod m, java.util.List<ITestNGMethod> methods)Finds TestNG methods that the specified TestNG method depends uponprotected static ITestNGMethod[]findDependedUponMethods(ITestNGMethod m, ITestNGMethod[] methods)Finds TestNG methods that the specified TestNG method depends uponprivate static java.lang.reflect.MethodfindMethodByName(ITestNGMethod testngMethod, java.lang.String regExp)Finds method based on regex and TestNGMethod.static voidfixMethodsWithClass(ITestNGMethod[] methods, ITestClass testCls, java.util.List<ITestNGMethod> methodList)static java.util.List<ITestNGMethod>getMethodsDependedUpon(ITestNGMethod method, ITestNGMethod[] methods, java.util.Comparator<ITestNGMethod> comparator)static java.util.List<ITestNGMethod>invokedMethodsToMethods(java.util.Collection<IInvokedMethod> invokedMethods)(package private) static booleanisAlwaysRun(IConfigurationAnnotation configurationAnnotation)(package private) static booleanisDisabled(ITestOrConfiguration test)protected static booleanisEnabled(java.lang.Class<?> objectClass, IAnnotationFinder finder)protected static booleanisEnabled(java.lang.reflect.Method m, IAnnotationFinder finder)protected static booleanisEnabled(ITestOrConfiguration test)private static MethodHelper.MatchResultsmatchMethod(ITestNGMethod[] methods, java.lang.String regexp)static java.util.List<ITestNGMethod>methodInstancesToMethods(java.util.List<IMethodInstance> methodInstances)static java.util.List<IMethodInstance>methodsToMethodInstances(java.util.List<ITestNGMethod> sl)private static java.util.List<ITestNGMethod>sortMethods(boolean forTests, java.util.List<ITestNGMethod> allMethods, java.util.Comparator<ITestNGMethod> comparator)private static java.util.Map<java.lang.Object,java.util.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, java.util.List<ITestNGMethod> sequentialList, java.util.List<ITestNGMethod> parallelList, java.util.Comparator<ITestNGMethod> comparator)static java.util.List<ITestNGMethod>uniqueMethodList(java.util.Collection<java.util.List<ITestNGMethod>> methods)Extracts the unique list ofITestNGMethods.
-
-
-
Field Detail
-
GRAPH_CACHE
private static final java.util.Map<ITestNGMethod[],Graph<ITestNGMethod>> GRAPH_CACHE
-
CANONICAL_NAME_CACHE
private static final java.util.Map<java.lang.reflect.Method,java.lang.String> CANONICAL_NAME_CACHE
-
MATCH_CACHE
private static final java.util.Map<Pair<java.lang.String,java.lang.String>,java.lang.Boolean> MATCH_CACHE
-
-
Method Detail
-
collectAndOrderMethods
public static ITestNGMethod[] collectAndOrderMethods(java.util.List<ITestNGMethod> methods, boolean forTests, RunInfo runInfo, IAnnotationFinder finder, boolean unique, java.util.List<ITestNGMethod> outExcludedMethods, java.util.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:
- list of ordered methods
-
findDependedUponMethods
protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, java.util.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:
- list of methods that match the criteria
-
findDependedUponMethods
protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, 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:
- list of methods that match the criteria
-
findMethodByName
private static java.lang.reflect.Method findMethodByName(ITestNGMethod testngMethod, java.lang.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 methodregExp- regex representing a method and/or related class name
-
isEnabled
protected static boolean isEnabled(java.lang.Class<?> objectClass, IAnnotationFinder finder)
-
isEnabled
protected static boolean isEnabled(java.lang.reflect.Method m, IAnnotationFinder finder)
-
isEnabled
protected static boolean isEnabled(ITestOrConfiguration test)
-
isDisabled
static boolean isDisabled(ITestOrConfiguration test)
-
isAlwaysRun
static boolean isAlwaysRun(IConfigurationAnnotation configurationAnnotation)
-
uniqueMethodList
public static java.util.List<ITestNGMethod> uniqueMethodList(java.util.Collection<java.util.List<ITestNGMethod>> methods)
Extracts the unique list ofITestNGMethods.
-
topologicalSort
private static Graph<ITestNGMethod> topologicalSort(ITestNGMethod[] methods, java.util.List<ITestNGMethod> sequentialList, java.util.List<ITestNGMethod> parallelList, java.util.Comparator<ITestNGMethod> comparator)
-
sortMethodsByInstance
private static java.util.Map<java.lang.Object,java.util.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 java.lang.String calculateMethodCanonicalName(ITestNGMethod m)
-
calculateMethodCanonicalName
private static java.lang.String calculateMethodCanonicalName(java.lang.reflect.Method m)
-
sortMethods
private static java.util.List<ITestNGMethod> sortMethods(boolean forTests, java.util.List<ITestNGMethod> allMethods, java.util.Comparator<ITestNGMethod> comparator)
-
getMethodsDependedUpon
public static java.util.List<ITestNGMethod> getMethodsDependedUpon(ITestNGMethod method, ITestNGMethod[] methods, java.util.Comparator<ITestNGMethod> comparator)
- Returns:
- A sorted array containing all the methods 'method' depends on
-
fixMethodsWithClass
public static void fixMethodsWithClass(ITestNGMethod[] methods, ITestClass testCls, java.util.List<ITestNGMethod> methodList)
-
invokedMethodsToMethods
public static java.util.List<ITestNGMethod> invokedMethodsToMethods(java.util.Collection<IInvokedMethod> invokedMethods)
-
methodsToMethodInstances
public static java.util.List<IMethodInstance> methodsToMethodInstances(java.util.List<ITestNGMethod> sl)
-
methodInstancesToMethods
public static java.util.List<ITestNGMethod> methodInstancesToMethods(java.util.List<IMethodInstance> methodInstances)
-
dumpInvokedMethodsInfoToConsole
public static void dumpInvokedMethodsInfoToConsole(java.util.Collection<IInvokedMethod> iInvokedMethods, int currentVerbosity)
-
calculateMethodCanonicalName
protected static java.lang.String calculateMethodCanonicalName(java.lang.Class<?> methodClass, java.lang.String methodName)
-
calculateTimeOut
protected static long calculateTimeOut(ITestNGMethod tm)
-
matchMethod
private static MethodHelper.MatchResults matchMethod(ITestNGMethod[] methods, java.lang.String regexp)
-
-