Package org.testng.internal
Class ConfigInvoker
- java.lang.Object
-
- org.testng.internal.BaseInvoker
-
- org.testng.internal.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_beforegroupsFailuresGroup failures must be synced as the Invoker is accessed concurrentlyprivate booleanm_continueOnFailedConfigurationprivate java.util.Set<ITestNGMethod>m_executedConfigMethodsprotected java.util.Map<ITestNGMethod,java.util.Set<java.lang.Object>>m_methodInvocationResultsTest methods whose configuration methods have failed.-
Fields inherited from class org.testng.internal.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 booleanclassConfigurationFailed(java.lang.Class<?> cls, java.lang.Object instance)private IConfigurablecomputeConfigurableInstance(ConstructorOrMethod method, java.lang.Object targetInstance)private static java.lang.ObjectcomputeInstance(java.lang.Object instance, java.lang.Object inst, ITestNGMethod tm)private static voidcopyAttributesFromNativelyInjectedTestResult(java.lang.Object[] source, ITestResult target)private java.util.Set<java.lang.Object>getInvocationResults(IClass testClass)private voidhandleConfigurationFailure(java.lang.Throwable ite, ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)private voidhandleConfigurationSkip(ITestNGMethod tm, ITestResult testResult, IConfigurationAnnotation annotation, ITestNGMethod currentTestMethod, java.lang.Object instance, XmlSuite suite)Marks the currentTestResultas skipped and invokes the listeners.private booleanhasConfigFailure(ITestNGMethod currentTestMethod)booleanhasConfigurationFailureFor(ITestNGMethod testNGMethod, java.lang.String[] groups, IClass testClass, java.lang.Object instance)voidinvokeAfterGroupsConfigurations(GroupConfigMethodArguments arguments)voidinvokeBeforeGroupsConfigurations(GroupConfigMethodArguments arguments)Filter all the beforeGroups methods and invoke only those that apply to the current test methodprivate voidinvokeConfigurationMethod(java.lang.Object targetInstance, ITestNGMethod tm, java.lang.Object[] params, ITestResult testResult)Effectively invokes a configuration method on all passed in instances.voidinvokeConfigurations(ConfigMethodArguments arguments)private static booleanisConfigMethodEligibleForScrutiny(ITestNGMethod tm)private static booleanisGroupLevelConfigurationMethod(ITestNGMethod itm)private voidrecordConfigurationInvocationFailed(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 voidrunConfigurationListeners(ITestResult tr, ITestNGMethod tm, boolean before)private voidsetClassInvocationFailure(java.lang.Class<?> clazz, java.lang.Object instance)private voidsetMethodInvocationFailure(ITestNGMethod method, java.lang.Object instance)private voidthrowConfigurationFailure(ITestResult testResult, java.lang.Throwable ex)-
Methods inherited from class org.testng.internal.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:
hasConfigurationFailureForin 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:
invokeBeforeGroupsConfigurationsin interfaceIConfigInvoker- Parameters:
arguments- - AGroupConfigMethodArgumentsobject.
-
isGroupLevelConfigurationMethod
private static boolean isGroupLevelConfigurationMethod(ITestNGMethod itm)
-
invokeAfterGroupsConfigurations
public void invokeAfterGroupsConfigurations(GroupConfigMethodArguments arguments)
- Specified by:
invokeAfterGroupsConfigurationsin interfaceIConfigInvoker
-
invokeConfigurations
public void invokeConfigurations(ConfigMethodArguments arguments)
- Specified by:
invokeConfigurationsin interfaceIConfigInvoker
-
invokeConfigurationMethod
private void invokeConfigurationMethod(java.lang.Object targetInstance, ITestNGMethod tm, java.lang.Object[] params, ITestResult testResult) throws java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessExceptionEffectively invokes a configuration method on all passed in instances.- Throws:
java.lang.reflect.InvocationTargetExceptionjava.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 currentTestResultas 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)
-
-