Modifier and Type | Class and Description |
---|---|
(package private) static class |
Invoker.CanRunFromClassPredicate |
(package private) static class |
Invoker.FailureContext |
private static class |
Invoker.ParameterBag
This class holds a
ParameterHolder or in case of an error, a non-null
TestResult containing the cause |
(package private) static interface |
Invoker.Predicate<K,T> |
(package private) static class |
Invoker.SameClassNamePredicate |
Modifier and Type | Field and Description |
---|---|
private static Invoker.Predicate<ITestNGMethod,IClass> |
CAN_RUN_FROM_CLASS
Predicate to filter methods
|
private IAnnotationFinder |
m_annotationFinder |
private java.util.Map<java.lang.String,java.lang.Boolean> |
m_beforegroupsFailures
Group failures must be synced as the Invoker is accessed concurrently
|
private java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.Object>> |
m_classInvocationResults
Class failures must be synced as the Invoker is accessed concurrently
|
private java.util.List<IClassListener> |
m_classListeners |
private IConfiguration |
m_configuration |
private boolean |
m_continueOnFailedConfiguration |
private java.util.Collection<IInvokedMethodListener> |
m_invokedMethodListeners |
private java.util.Map<ITestNGMethod,java.util.Set<java.lang.Object>> |
m_methodInvocationResults
Test methods whose configuration methods have failed.
|
private ITestResultNotifier |
m_notifier |
private boolean |
m_skipFailedInvocationCounts |
private SuiteRunState |
m_suiteState |
private ITestContext |
m_testContext |
private static Invoker.Predicate<ITestNGMethod,IClass> |
SAME_CLASS
Predicate to filter methods
|
Constructor and Description |
---|
Invoker(IConfiguration configuration,
ITestContext testContext,
ITestResultNotifier notifier,
SuiteRunState state,
boolean skipFailedInvocationCounts,
java.util.Collection<IInvokedMethodListener> invokedMethodListeners,
java.util.List<IClassListener> classListeners) |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
checkDependencies(ITestNGMethod testMethod,
ITestNGMethod[] allTestMethods)
Checks to see of the test method has certain dependencies that prevents
TestNG from executing it
|
private boolean |
classConfigurationFailed(java.lang.Class<?> cls) |
(package private) void |
collectResults(ITestNGMethod testMethod,
ITestResult result) |
private boolean |
confInvocationPassed(ITestNGMethod method,
ITestNGMethod currentTestMethod,
IClass testClass,
java.lang.Object instance) |
private Invoker.ParameterBag |
createParameters(ITestNGMethod testMethod,
java.util.Map<java.lang.String,java.lang.String> parameters,
java.util.Map<java.lang.String,java.lang.String> allParameterNames,
XmlSuite suite,
ITestContext testContext,
java.lang.Object fedInstance) |
private boolean |
dependsOnMethods(ITestNGMethod tm) |
private ITestNGMethod[] |
filterConfigurationMethods(ITestNGMethod tm,
ITestNGMethod[] methods,
boolean isBefore)
The array of methods contains @BeforeMethods if isBefore if true, @AfterMethods
otherwise.
|
private ITestNGMethod[] |
filterMethods(IClass testClass,
ITestNGMethod[] methods,
Invoker.Predicate<ITestNGMethod,IClass> predicate) |
private XmlClass[] |
findClassesInSameTest(java.lang.Class<?> cls,
XmlSuite suite) |
private java.lang.Object |
getMethodInvocationToken(ITestNGMethod method,
java.lang.Object instance) |
private java.lang.Object[] |
getParametersFromIndex(java.util.Iterator<java.lang.Object[]> parametersValues,
int index) |
private void |
handleConfigurationFailure(java.lang.Throwable ite,
ITestNGMethod tm,
ITestResult testResult,
IConfigurationAnnotation annotation,
ITestNGMethod currentTestMethod,
java.lang.Object instance,
XmlSuite suite) |
private void |
handleConfigurationSkip(ITestNGMethod tm,
ITestResult testResult,
IConfigurationAnnotation annotation,
ITestNGMethod currentTestMethod,
java.lang.Object instance,
XmlSuite suite)
Marks the current
TestResult as skipped and invokes the listeners. |
private void |
handleException(java.lang.Throwable throwable,
ITestNGMethod testMethod,
ITestResult testResult,
int failureCount)
An exception was thrown by the test, determine if this method
should be marked as a failure or as failure_but_within_successPercentage
|
(package private) void |
handleInvocationResults(ITestNGMethod testMethod,
java.util.List<ITestResult> result,
ExpectedExceptionsHolder expectedExceptionsHolder,
Invoker.FailureContext failure) |
private Invoker.ParameterBag |
handleParameters(ITestNGMethod testMethod,
java.lang.Object instance,
java.util.Map<java.lang.String,java.lang.String> allParameterNames,
java.util.Map<java.lang.String,java.lang.String> parameters,
java.lang.Object[] parameterValues,
XmlSuite suite,
ITestContext testContext,
java.lang.Object fedInstance,
ITestResult testResult) |
private boolean |
haveBeenRunSuccessfully(ITestNGMethod testMethod,
ITestNGMethod[] methods) |
private java.lang.Object[] |
injectParameters(java.lang.Object[] parameterValues,
java.lang.reflect.Method method,
ITestContext context,
ITestResult testResult)
Gets an array of parameter values returned by data provider or the ones that
are injected based on parameter type.
|
private void |
invokeAfterGroupsConfigurations(ITestClass testClass,
ITestNGMethod currentTestMethod,
ConfigurationGroupMethods groupMethods,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.Object instance) |
private void |
invokeBeforeGroupsConfigurations(ITestClass testClass,
ITestNGMethod currentTestMethod,
ConfigurationGroupMethods groupMethods,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.Object instance)
Filter all the beforeGroups methods and invoke only those that apply
to the current test method
|
private void |
invokeConfigurationMethod(java.lang.Object targetInstance,
ITestNGMethod tm,
java.lang.Object[] params,
ITestResult testResult)
Effectively invokes a configuration method on all passed in instances.
|
void |
invokeConfigurations(IClass testClass,
ITestNGMethod[] allMethods,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.Object[] parameterValues,
java.lang.Object instance)
Invoke configuration methods if they belong to the same TestClass passed
in parameter..
|
private void |
invokeConfigurations(IClass testClass,
ITestNGMethod currentTestMethod,
ITestNGMethod[] allMethods,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> params,
java.lang.Object[] parameterValues,
java.lang.Object instance,
ITestResult testMethodResult) |
private ITestResult |
invokeMethod(java.lang.Object instance,
ITestNGMethod tm,
java.lang.Object[] parameterValues,
int parametersIndex,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> params,
ITestClass testClass,
ITestNGMethod[] beforeMethods,
ITestNGMethod[] afterMethods,
ConfigurationGroupMethods groupMethods,
Invoker.FailureContext failureContext) |
private java.util.List<ITestResult> |
invokePooledTestMethods(ITestNGMethod testMethod,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> parameters,
ConfigurationGroupMethods groupMethods,
ITestContext testContext)
Invokes a method that has a specified threadPoolSize.
|
protected ITestResult |
invokeTestMethod(java.lang.Object instance,
ITestNGMethod tm,
java.lang.Object[] parameterValues,
int parametersIndex,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> params,
ITestClass testClass,
ITestNGMethod[] beforeMethods,
ITestNGMethod[] afterMethods,
ConfigurationGroupMethods groupMethods,
Invoker.FailureContext failureContext)
invokeTestMethods() eventually converge here to invoke a single @Test method.
|
java.util.List<ITestResult> |
invokeTestMethods(ITestNGMethod testMethod,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> testParameters,
ConfigurationGroupMethods groupMethods,
java.lang.Object instance,
ITestContext testContext)
Invoke all the test methods.
|
private boolean |
isAlwaysRun(IConfigurationAnnotation configurationAnnotation)
Is the
IConfiguration marked as alwaysRun. |
private boolean |
isSkipExceptionAndSkip(java.lang.Throwable ite) |
private java.util.Set<ITestResult> |
keepSameInstances(ITestNGMethod method,
java.util.Set<ITestResult> results) |
private void |
log(int level,
java.lang.String s) |
private boolean |
noListenersPresent() |
private void |
recordConfigurationInvocationFailed(ITestNGMethod tm,
IClass testClass,
IConfigurationAnnotation annotation,
ITestNGMethod currentTestMethod,
java.lang.Object instance,
XmlSuite suite)
Record internally the failure of a Configuration, so that we can determine
later if @Test should be skipped.
|
private ITestResult |
registerSkippedTestResult(ITestNGMethod testMethod,
java.lang.Object instance,
long start,
java.lang.Throwable throwable) |
private void |
removeResultsToRetryFromResult(java.util.List<ITestResult> resultsToRetry,
java.util.List<ITestResult> result,
Invoker.FailureContext failure) |
(package private) int |
retryFailed(java.lang.Object instance,
ITestNGMethod tm,
XmlSuite suite,
ITestClass testClass,
ITestNGMethod[] beforeMethods,
ITestNGMethod[] afterMethods,
ConfigurationGroupMethods groupMethods,
java.util.List<ITestResult> result,
int failureCount,
ExpectedExceptionsHolder expectedExceptionHolder,
ITestContext testContext,
java.util.Map<java.lang.String,java.lang.String> parameters,
int parametersIndex) |
private void |
runConfigurationListeners(ITestResult tr,
boolean before) |
private void |
runInvokedMethodListeners(InvokedMethodListenerMethod listenerMethod,
IInvokedMethod invokedMethod,
ITestResult testResult) |
(package private) void |
runTestListeners(ITestResult tr) |
static void |
runTestListeners(ITestResult tr,
java.util.List<ITestListener> listeners) |
private java.util.List<ITestResult> |
runWorkers(ITestNGMethod testMethod,
java.util.List<IWorker<ITestNGMethod>> workers,
int threadPoolSize,
ConfigurationGroupMethods groupMethods,
XmlSuite suite,
java.util.Map<java.lang.String,java.lang.String> parameters)
To reduce thread contention and also to correctly handle thread-confinement
this method invokes the @BeforeGroups and @AfterGroups corresponding to the current @Test method.
|
private void |
setClassInvocationFailure(java.lang.Class<?> clazz,
java.lang.Object instance) |
private void |
setMethodInvocationFailure(ITestNGMethod method,
java.lang.Object instance) |
private void |
throwConfigurationFailure(ITestResult testResult,
java.lang.Throwable ex) |
private final ITestContext m_testContext
private final ITestResultNotifier m_notifier
private final IAnnotationFinder m_annotationFinder
private final SuiteRunState m_suiteState
private final boolean m_skipFailedInvocationCounts
private final java.util.Collection<IInvokedMethodListener> m_invokedMethodListeners
private final boolean m_continueOnFailedConfiguration
private final java.util.List<IClassListener> m_classListeners
private java.util.Map<java.lang.String,java.lang.Boolean> m_beforegroupsFailures
private java.util.Map<java.lang.Class<?>,java.util.Set<java.lang.Object>> m_classInvocationResults
private java.util.Map<ITestNGMethod,java.util.Set<java.lang.Object>> m_methodInvocationResults
private IConfiguration m_configuration
private static Invoker.Predicate<ITestNGMethod,IClass> CAN_RUN_FROM_CLASS
private static final Invoker.Predicate<ITestNGMethod,IClass> SAME_CLASS
public Invoker(IConfiguration configuration, ITestContext testContext, ITestResultNotifier notifier, SuiteRunState state, boolean skipFailedInvocationCounts, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, java.util.List<IClassListener> classListeners)
private void setClassInvocationFailure(java.lang.Class<?> clazz, java.lang.Object instance)
private void setMethodInvocationFailure(ITestNGMethod method, java.lang.Object instance)
public void invokeConfigurations(IClass testClass, ITestNGMethod[] allMethods, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> params, java.lang.Object[] parameterValues, java.lang.Object instance)
invokeConfigurations
in interface IInvoker
testClass
- the class whose configuration methods must be runprivate void invokeConfigurations(IClass testClass, ITestNGMethod currentTestMethod, ITestNGMethod[] allMethods, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> params, java.lang.Object[] parameterValues, java.lang.Object instance, ITestResult testMethodResult)
private void handleConfigurationSkip(ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)
TestResult
as skipped and invokes the listeners.private boolean isAlwaysRun(IConfigurationAnnotation configurationAnnotation)
IConfiguration
marked as alwaysRun.private void handleConfigurationFailure(java.lang.Throwable ite, ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)
private XmlClass[] findClassesInSameTest(java.lang.Class<?> cls, XmlSuite suite)
private void recordConfigurationInvocationFailed(ITestNGMethod tm, IClass testClass, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)
private boolean classConfigurationFailed(java.lang.Class<?> cls)
private boolean confInvocationPassed(ITestNGMethod method, ITestNGMethod currentTestMethod, IClass testClass, java.lang.Object instance)
private java.lang.Object getMethodInvocationToken(ITestNGMethod method, java.lang.Object instance)
private void invokeConfigurationMethod(java.lang.Object targetInstance, ITestNGMethod tm, java.lang.Object[] params, ITestResult testResult) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
IInvokedMethodListener
better.targetInstance
- the instance to invoke the configuration method ontm
- the configuration methodparams
- the parameters needed for method invocationtestResult
- java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
private void throwConfigurationFailure(ITestResult testResult, java.lang.Throwable ex)
private void runInvokedMethodListeners(InvokedMethodListenerMethod listenerMethod, IInvokedMethod invokedMethod, ITestResult testResult)
private boolean noListenersPresent()
private ITestResult invokeMethod(java.lang.Object instance, ITestNGMethod tm, java.lang.Object[] parameterValues, int parametersIndex, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> params, ITestClass testClass, ITestNGMethod[] beforeMethods, ITestNGMethod[] afterMethods, ConfigurationGroupMethods groupMethods, Invoker.FailureContext failureContext)
void collectResults(ITestNGMethod testMethod, ITestResult result)
private ITestNGMethod[] filterConfigurationMethods(ITestNGMethod tm, ITestNGMethod[] methods, boolean isBefore)
protected ITestResult invokeTestMethod(java.lang.Object instance, ITestNGMethod tm, java.lang.Object[] parameterValues, int parametersIndex, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> params, ITestClass testClass, ITestNGMethod[] beforeMethods, ITestNGMethod[] afterMethods, ConfigurationGroupMethods groupMethods, Invoker.FailureContext failureContext)
IHookable
private void invokeBeforeGroupsConfigurations(ITestClass testClass, ITestNGMethod currentTestMethod, ConfigurationGroupMethods groupMethods, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> params, java.lang.Object instance)
private void invokeAfterGroupsConfigurations(ITestClass testClass, ITestNGMethod currentTestMethod, ConfigurationGroupMethods groupMethods, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> params, java.lang.Object instance)
private java.lang.Object[] getParametersFromIndex(java.util.Iterator<java.lang.Object[]> parametersValues, int index)
int retryFailed(java.lang.Object instance, ITestNGMethod tm, XmlSuite suite, ITestClass testClass, ITestNGMethod[] beforeMethods, ITestNGMethod[] afterMethods, ConfigurationGroupMethods groupMethods, java.util.List<ITestResult> result, int failureCount, ExpectedExceptionsHolder expectedExceptionHolder, ITestContext testContext, java.util.Map<java.lang.String,java.lang.String> parameters, int parametersIndex)
private Invoker.ParameterBag createParameters(ITestNGMethod testMethod, java.util.Map<java.lang.String,java.lang.String> parameters, java.util.Map<java.lang.String,java.lang.String> allParameterNames, XmlSuite suite, ITestContext testContext, java.lang.Object fedInstance)
public java.util.List<ITestResult> invokeTestMethods(ITestNGMethod testMethod, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> testParameters, ConfigurationGroupMethods groupMethods, java.lang.Object instance, ITestContext testContext)
invokeTestMethod(Object, ITestNGMethod, Object[], int, XmlSuite, Map, ITestClass, ITestNGMethod[], ITestNGMethod[], ConfigurationGroupMethods, FailureContext)
and this would simplify the implementation (see how DataTestMethodWorker is used)invokeTestMethods
in interface IInvoker
private ITestResult registerSkippedTestResult(ITestNGMethod testMethod, java.lang.Object instance, long start, java.lang.Throwable throwable)
private java.lang.Object[] injectParameters(java.lang.Object[] parameterValues, java.lang.reflect.Method method, ITestContext context, ITestResult testResult) throws TestNGException
NoInjection
annotationparameterValues
- parameter values from a data providermethod
- method to be invokedcontext
- test contexttestResult
- test resultTestNGException
private Invoker.ParameterBag handleParameters(ITestNGMethod testMethod, java.lang.Object instance, java.util.Map<java.lang.String,java.lang.String> allParameterNames, java.util.Map<java.lang.String,java.lang.String> parameters, java.lang.Object[] parameterValues, XmlSuite suite, ITestContext testContext, java.lang.Object fedInstance, ITestResult testResult)
private java.util.List<ITestResult> invokePooledTestMethods(ITestNGMethod testMethod, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext)
void handleInvocationResults(ITestNGMethod testMethod, java.util.List<ITestResult> result, ExpectedExceptionsHolder expectedExceptionsHolder, Invoker.FailureContext failure)
private boolean isSkipExceptionAndSkip(java.lang.Throwable ite)
private void removeResultsToRetryFromResult(java.util.List<ITestResult> resultsToRetry, java.util.List<ITestResult> result, Invoker.FailureContext failure)
private java.util.List<ITestResult> runWorkers(ITestNGMethod testMethod, java.util.List<IWorker<ITestNGMethod>> workers, int threadPoolSize, ConfigurationGroupMethods groupMethods, XmlSuite suite, java.util.Map<java.lang.String,java.lang.String> parameters)
private java.lang.String checkDependencies(ITestNGMethod testMethod, ITestNGMethod[] allTestMethods)
testMethod
- test method being checked forprivate java.util.Set<ITestResult> keepSameInstances(ITestNGMethod method, java.util.Set<ITestResult> results)
private boolean haveBeenRunSuccessfully(ITestNGMethod testMethod, ITestNGMethod[] methods)
private void handleException(java.lang.Throwable throwable, ITestNGMethod testMethod, ITestResult testResult, int failureCount)
private ITestNGMethod[] filterMethods(IClass testClass, ITestNGMethod[] methods, Invoker.Predicate<ITestNGMethod,IClass> predicate)
private boolean dependsOnMethods(ITestNGMethod tm)
private void runConfigurationListeners(ITestResult tr, boolean before)
void runTestListeners(ITestResult tr)
public static void runTestListeners(ITestResult tr, java.util.List<ITestListener> listeners)
private void log(int level, java.lang.String s)