Package org.testng.internal.invokers
Class ConfigInvoker
- java.lang.Object
-
- org.testng.internal.invokers.BaseInvoker
-
- org.testng.internal.invokers.ConfigInvoker
-
- All Implemented Interfaces:
IConfigInvoker
class ConfigInvoker extends BaseInvoker implements IConfigInvoker
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.Boolean>
m_beforegroupsFailures
Group failures must be synced as the Invoker is accessed concurrentlyprivate boolean
m_continueOnFailedConfiguration
private java.util.Set<ITestNGMethod>
m_executedConfigMethods
protected java.util.Map<ITestNGMethod,java.util.Set<java.lang.Object>>
m_methodInvocationResults
Test methods whose configuration methods have failed.-
Fields inherited from class org.testng.internal.invokers.BaseInvoker
m_classInvocationResults, m_configuration, m_notifier, m_suiteState, m_testContext
-
-
Constructor Summary
Constructors Constructor Description ConfigInvoker(ITestResultNotifier notifier, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, ITestContext testContext, SuiteRunState suiteState, IConfiguration configuration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
classConfigurationFailed(java.lang.Class<?> cls, java.lang.Object instance)
private IConfigurable
computeConfigurableInstance(ConstructorOrMethod method, java.lang.Object targetInstance)
private static java.lang.Object
computeInstance(java.lang.Object instance, java.lang.Object inst, ITestNGMethod tm)
private static void
copyAttributesFromNativelyInjectedTestResult(java.lang.Object[] source, ITestResult target)
private java.util.Set<java.lang.Object>
getInvocationResults(IClass testClass)
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 currentTestResult
as skipped and invokes the listeners.private boolean
hasConfigFailure(ITestNGMethod currentTestMethod)
boolean
hasConfigurationFailureFor(ITestNGMethod testNGMethod, java.lang.String[] groups, IClass testClass, java.lang.Object instance)
void
invokeAfterGroupsConfigurations(GroupConfigMethodArguments arguments)
void
invokeBeforeGroupsConfigurations(GroupConfigMethodArguments arguments)
Filter all the beforeGroups methods and invoke only those that apply to the current test methodprivate 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(ConfigMethodArguments arguments)
private static boolean
isConfigMethodEligibleForScrutiny(ITestNGMethod tm)
private static boolean
isGroupLevelConfigurationMethod(ITestNGMethod itm)
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 void
runConfigurationListeners(ITestResult tr, ITestNGMethod tm, boolean before)
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)
-
Methods inherited from class org.testng.internal.invokers.BaseInvoker
annotationFinder, handleException, isSkipExceptionAndSkip, log, runInvokedMethodListeners
-
-
-
-
Field Detail
-
m_methodInvocationResults
protected final java.util.Map<ITestNGMethod,java.util.Set<java.lang.Object>> m_methodInvocationResults
Test methods whose configuration methods have failed.
-
m_continueOnFailedConfiguration
private final boolean m_continueOnFailedConfiguration
-
m_executedConfigMethods
private final java.util.Set<ITestNGMethod> m_executedConfigMethods
-
m_beforegroupsFailures
private final java.util.Map<java.lang.String,java.lang.Boolean> m_beforegroupsFailures
Group failures must be synced as the Invoker is accessed concurrently
-
-
Constructor Detail
-
ConfigInvoker
public ConfigInvoker(ITestResultNotifier notifier, java.util.Collection<IInvokedMethodListener> invokedMethodListeners, ITestContext testContext, SuiteRunState suiteState, IConfiguration configuration)
-
-
Method Detail
-
hasConfigurationFailureFor
public boolean hasConfigurationFailureFor(ITestNGMethod testNGMethod, java.lang.String[] groups, IClass testClass, java.lang.Object instance)
- Specified by:
hasConfigurationFailureFor
in interfaceIConfigInvoker
- Returns:
- false if this class has successfully run all its @Configuration method or true if at least one of these methods failed.
-
invokeBeforeGroupsConfigurations
public void invokeBeforeGroupsConfigurations(GroupConfigMethodArguments arguments)
Filter all the beforeGroups methods and invoke only those that apply to the current test method- Specified by:
invokeBeforeGroupsConfigurations
in interfaceIConfigInvoker
- Parameters:
arguments
- - AGroupConfigMethodArguments
object.
-
isGroupLevelConfigurationMethod
private static boolean isGroupLevelConfigurationMethod(ITestNGMethod itm)
-
invokeAfterGroupsConfigurations
public void invokeAfterGroupsConfigurations(GroupConfigMethodArguments arguments)
- Specified by:
invokeAfterGroupsConfigurations
in interfaceIConfigInvoker
-
invokeConfigurations
public void invokeConfigurations(ConfigMethodArguments arguments)
- Specified by:
invokeConfigurations
in interfaceIConfigInvoker
-
invokeConfigurationMethod
private void invokeConfigurationMethod(java.lang.Object targetInstance, ITestNGMethod tm, java.lang.Object[] params, ITestResult testResult) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
Effectively invokes a configuration method on all passed in instances.- Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
-
throwConfigurationFailure
private void throwConfigurationFailure(ITestResult testResult, java.lang.Throwable ex)
-
computeConfigurableInstance
private IConfigurable computeConfigurableInstance(ConstructorOrMethod method, java.lang.Object targetInstance)
-
runConfigurationListeners
private void runConfigurationListeners(ITestResult tr, ITestNGMethod tm, boolean before)
-
handleConfigurationSkip
private void handleConfigurationSkip(ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)
Marks the currentTestResult
as skipped and invokes the listeners.
-
hasConfigFailure
private boolean hasConfigFailure(ITestNGMethod currentTestMethod)
-
handleConfigurationFailure
private void handleConfigurationFailure(java.lang.Throwable ite, ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)
-
isConfigMethodEligibleForScrutiny
private static boolean isConfigMethodEligibleForScrutiny(ITestNGMethod tm)
-
classConfigurationFailed
private boolean classConfigurationFailed(java.lang.Class<?> cls, java.lang.Object instance)
- Returns:
- true if this class or a parent class failed to initialize.
-
copyAttributesFromNativelyInjectedTestResult
private static void copyAttributesFromNativelyInjectedTestResult(java.lang.Object[] source, ITestResult target)
-
setMethodInvocationFailure
private void setMethodInvocationFailure(ITestNGMethod method, java.lang.Object instance)
-
setClassInvocationFailure
private void setClassInvocationFailure(java.lang.Class<?> clazz, java.lang.Object instance)
-
recordConfigurationInvocationFailed
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.
-
computeInstance
private static java.lang.Object computeInstance(java.lang.Object instance, java.lang.Object inst, ITestNGMethod tm)
-
getInvocationResults
private java.util.Set<java.lang.Object> getInvocationResults(IClass testClass)
-
-