Top Description Inners Fields Constructors Methods
org.testng.internal

public Class MethodHelper

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, java.util.Arrays, .Collection, .Comparator, .List, .Map, .Objects, .Optional, .Set, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicReference, java.util.function.Predicate, java.util.regex.Pattern, java.util.stream.Collectors, .Stream, org.testng.IMethodInstance, .ITestClass, .ITestNGMethod, .TestNGException, org.testng.annotations.IConfigurationAnnotation, .ITestAnnotation, .ITestOrConfiguration, org.testng.collections.Lists, .Sets, org.testng.internal.annotations.AnnotationHelper, .IAnnotationFinder, org.testng.internal.collections.Pair, org.testng.internal.invokers.IInvocationStatus, org.testng.util.TimeUtils, org.testng.xml.XmlTest

Collection of helper methods to help sort and arrange methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Map<Method, String>
private static final Map<ITestNGMethod[], Graph<ITestNGMethod>>
private static final Map<Pair<String, String>, Boolean>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Comparator<ITestNGMethod>
protected static String
private static String
protected static String
calculateMethodCanonicalName(Class<?> methodClass, String methodName)

public static long
public static void
clear(Stream<Method> methods)

public static ITestNGMethod[]

Returns:

an array of ordered methods
collectAndOrderMethods
(List<ITestNGMethod>
methods to be worked on
methods
,
boolean
true for test methods, false for configuration methods
forTests
,
RunInfo
- RunInfo object.
runInfo
,
IAnnotationFinder
annotation finder
finder
,
boolean
true for unique methods, false otherwise
unique
,
List<ITestNGMethod>
- A List of excluded ITestNGMethod methods.
outExcludedMethods
,
Comparator<ITestNGMethod> comparator)

Collects and orders test or configuration methods

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

private static Pair<String, Predicate<ITestNGMethod>>
protected static ITestNGMethod[]

Returns:

an array of methods that match the criteria
findDependedUponMethods
(ITestNGMethod
TestNG method
m
,
List<ITestNGMethod>
list of methods to search for depended upon methods
methods
)

Finds TestNG methods that the specified TestNG method depends upon

public static ITestNGMethod[]

Returns:

an array of methods that match the criteria
findDependedUponMethods
(ITestNGMethod
TestNG method
m
,
ITestNGMethod[]
list of methods to search for depended upon methods
incoming
)

Finds TestNG methods that the specified TestNG method depends upon

private static Method
findMethodByName(ITestNGMethod
TestNG method
testngMethod
,
String
regex representing a method and/or related class name
regExp
)

Finds method based on regex and TestNGMethod.

public static void
public static List<ITestNGMethod>

Returns:

A sorted array containing all the methods 'method' depends on
getMethodsDependedUpon
(ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator)

public static boolean
isAlwaysRun(IConfigurationAnnotation configurationAnnotation)

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

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

public static List<ITestNGMethod>
public static List<IMethodInstance>
private static List<ITestNGMethod>
sortMethods(boolean forTests, List<ITestNGMethod> allMethods, Comparator<ITestNGMethod> comparator)

private static Map<Object, List<ITestNGMethod>>

Returns:

Map of Instances as the keys and the methods associated with the instance as the values
sortMethodsByInstance
(ITestNGMethod[]
Methods to be sorted
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, final Comparator<ITestNGMethod> comparator)

public static List<ITestNGMethod>
uniqueMethodList(Collection<List<ITestNGMethod>> methods)

Extracts the unique list of ITestNGMethods.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CANONICAL_NAME_CACHEback to summary
private static final Map<Method, String> CANONICAL_NAME_CACHE
GRAPH_CACHEback to summary
private static final Map<ITestNGMethod[], Graph<ITestNGMethod>> GRAPH_CACHE
MATCH_CACHEback to summary
private static final Map<Pair<String, String>, Boolean> MATCH_CACHE

Constructor Detail

MethodHelperback to summary
public MethodHelper()

Method Detail

bubbleUpIndependentMethodsFirstback to summary
private static Comparator<ITestNGMethod> bubbleUpIndependentMethodsFirst()
calculateMethodCanonicalNameback to summary
protected static String calculateMethodCanonicalName(ITestNGMethod m)
calculateMethodCanonicalNameback to summary
private static String calculateMethodCanonicalName(Method m)
calculateMethodCanonicalNameback to summary
protected static String calculateMethodCanonicalName(Class<?> methodClass, String methodName)
calculateTimeOutback to summary
public static long calculateTimeOut(ITestNGMethod tm)
clearback to summary
public static void clear(Stream<Method> methods)
collectAndOrderMethodsback to summary
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:List<ITestNGMethod>

methods to be worked on

forTests:boolean

true for test methods, false for configuration methods

runInfo:RunInfo

- RunInfo object.

finder:IAnnotationFinder

annotation finder

unique:boolean

true for unique methods, false otherwise

outExcludedMethods:List<ITestNGMethod>

- A List of excluded ITestNGMethod methods.

Returns:ITestNGMethod[]

an array of ordered methods

dumpInvokedMethodInfoToConsoleback to summary
public static void dumpInvokedMethodInfoToConsole(ITestNGMethod[] methods, int currentVerbosity)
filterToUseback to summary
private static Pair<String, Predicate<ITestNGMethod>> filterToUse(ITestNGMethod m)
findDependedUponMethodsback to summary
protected static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, List<ITestNGMethod> methods)

Finds TestNG methods that the specified TestNG method depends upon

Parameters
m:ITestNGMethod

TestNG method

methods:List<ITestNGMethod>

list of methods to search for depended upon methods

Returns:ITestNGMethod[]

an array of methods that match the criteria

findDependedUponMethodsback to summary
public static ITestNGMethod[] findDependedUponMethods(ITestNGMethod m, ITestNGMethod[] incoming)

Finds TestNG methods that the specified TestNG method depends upon

Parameters
m:ITestNGMethod

TestNG method

incoming:ITestNGMethod[]

list of methods to search for depended upon methods

Returns:ITestNGMethod[]

an array of methods that match the criteria

findMethodByNameback to summary
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:ITestNGMethod

TestNG method

regExp:String

regex representing a method and/or related class name

fixMethodsWithClassback to summary
public static void fixMethodsWithClass(ITestNGMethod[] methods, ITestClass testCls, List<ITestNGMethod> methodList)
getMethodsDependedUponback to summary
public static List<ITestNGMethod> getMethodsDependedUpon(ITestNGMethod method, ITestNGMethod[] methods, Comparator<ITestNGMethod> comparator)
Returns:List<ITestNGMethod>

A sorted array containing all the methods 'method' depends on

isAlwaysRunback to summary
public static boolean isAlwaysRun(IConfigurationAnnotation configurationAnnotation)
isConfigurationMethodback to summary
private static boolean isConfigurationMethod(ITestNGMethod tm)
isEnabledback to summary
public static boolean isEnabled(Class<?> objectClass, IAnnotationFinder finder)
isEnabledback to summary
public static boolean isEnabled(Method m, IAnnotationFinder finder)
isEnabledback to summary
public static boolean isEnabled(ITestOrConfiguration test)
isIndependentback to summary
private static boolean isIndependent(ITestNGMethod tm)
matchMethodback to summary
private static MethodHelper.MatchResults matchMethod(ITestNGMethod[] methods, String regexp)
methodInstancesToMethodsback to summary
public static List<ITestNGMethod> methodInstancesToMethods(List<IMethodInstance> methodInstances)
methodsToMethodInstancesback to summary
public static List<IMethodInstance> methodsToMethodInstances(List<ITestNGMethod> sl)
sortMethodsback to summary
private static List<ITestNGMethod> sortMethods(boolean forTests, List<ITestNGMethod> allMethods, Comparator<ITestNGMethod> comparator)
sortMethodsByInstanceback to summary
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:ITestNGMethod[]

Methods to be sorted

Returns:Map<Object, List<ITestNGMethod>>

Map of Instances as the keys and the methods associated with the instance as the values

topologicalSortback to summary
private static Graph<ITestNGMethod> topologicalSort(ITestNGMethod[] methods, List<ITestNGMethod> sequentialList, List<ITestNGMethod> parallelList, final Comparator<ITestNGMethod> comparator)
uniqueMethodListback to summary
public static List<ITestNGMethod> uniqueMethodList(Collection<List<ITestNGMethod>> methods)

Extracts the unique list of ITestNGMethods.

org.testng.internal back to summary

private Class MethodHelper.MatchResults

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
private final List<ITestNGMethod>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

foundAtLeastAMethodback to summary
private boolean foundAtLeastAMethod
matchedMethodsback to summary
private final List<ITestNGMethod> matchedMethods

Constructor Detail

MatchResultsback to summary
private MatchResults()