Package org.testng.internal.invokers
Class TestInvoker
- java.lang.Object
-
- org.testng.internal.invokers.BaseInvoker
-
- org.testng.internal.invokers.TestInvoker
-
- All Implemented Interfaces:
ITestInvoker
class TestInvoker extends BaseInvoker implements ITestInvoker
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
TestInvoker.MethodInvocationAgent
private static class
TestInvoker.StatusHolder
-
Nested classes/interfaces inherited from interface org.testng.internal.invokers.ITestInvoker
ITestInvoker.FailureContext
-
-
Field Summary
Fields Modifier and Type Field Description private DataProviderHolder
holder
private ConfigInvoker
invoker
private java.util.List<IClassListener>
m_classListeners
private boolean
m_skipFailedInvocationCounts
-
Fields inherited from class org.testng.internal.invokers.BaseInvoker
m_classInvocationResults, m_configuration, m_notifier, m_suiteState, m_testContext, NULL_OBJECT
-
-
Constructor Summary
Constructors Constructor Description TestInvoker(ITestResultNotifier m_notifier, ITestContext m_testContext, SuiteRunState m_suiteState, IConfiguration m_configuration, java.util.Collection<IInvokedMethodListener> m_invokedMethodListeners, DataProviderHolder holder, java.util.List<IClassListener> m_classListeners, boolean m_skipFailedInvocationCounts, ConfigInvoker invoker, SuiteRunner suiteRunner)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private DataProviderHolder
buildDataProviderHolder()
private java.lang.String
checkDependencies(ITestNGMethod testMethod)
Checks to see of the test method has certain dependencies that prevents TestNG from executing itprivate static void
cleanInterruptStatus()
private void
collectResults(ITestNGMethod testMethod, ITestResult result)
private TestInvoker.StatusHolder
considerExceptions(ITestNGMethod tm, ITestResult testResult, ExpectedExceptionsHolder exceptionsHolder, ITestInvoker.FailureContext failure)
private java.util.Collection<IDataProviderListener>
dataProviderListeners()
private boolean
failuresPresentInUpstreamDependency(ITestNGMethod testMethod, ITestNGMethod[] methods)
ITestResultNotifier
getNotifier()
private void
handleInvocationResult(ITestNGMethod testMethod, ITestResult testResult, ITestInvoker.FailureContext failure, TestInvoker.StatusHolder holder, boolean willRetry)
void
invokeListenersForSkippedTestResult(ITestResult r, IInvokedMethod invokedMethod)
private ITestResult
invokeMethod(TestMethodArguments arguments, XmlSuite suite, ITestInvoker.FailureContext failureContext)
private java.util.List<ITestResult>
invokePooledTestMethods(ITestNGMethod testMethod, java.util.Map<java.lang.String,java.lang.String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext)
Invokes a method that has a specified threadPoolSize.ITestResult
invokeTestMethod(TestMethodArguments arguments, XmlSuite suite, ITestInvoker.FailureContext failureContext)
invokeTestMethods() eventually converge here to invoke a single @Test method.java.util.List<ITestResult>
invokeTestMethods(ITestNGMethod testMethod, ConfigurationGroupMethods groupMethods, java.lang.Object instance, ITestContext context)
private java.util.Set<ITestResult>
keepSameInstances(ITestNGMethod method, java.util.Set<ITestResult> results)
ITestResult
registerSkippedTestResult(ITestNGMethod testMethod, long start, java.lang.Throwable throwable, ITestResult source)
ITestInvoker.FailureContext
retryFailed(TestMethodArguments arguments, java.util.List<ITestResult> result, int failureCount, ITestContext testContext)
private void
runAfterConfigurations(TestMethodArguments arguments, XmlSuite suite, TestResult testResult)
private void
runAfterGroupsConfigurations(TestMethodArguments arguments)
private void
runConfigMethods(TestMethodArguments arguments, XmlSuite suite, TestResult testResult, ITestNGMethod[] teardownConfigMethods)
void
runTestResultListener(ITestResult tr)
private java.util.List<ITestResult>
runWorkers(ITestNGMethod testMethod, java.util.List<IWorker<ITestNGMethod>> workers, int threadPoolSize, ConfigurationGroupMethods groupMethods, 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 static void
setTestStatus(ITestResult result, int status)
private boolean
shouldRetryTestMethod(ITestNGMethod testMethod, ITestResult testResult, ITestInvoker.FailureContext failure, TestInvoker.StatusHolder holder)
private static void
updateStatusHolderAccordingToTestResult(ITestResult testResult, TestInvoker.StatusHolder holder)
-
Methods inherited from class org.testng.internal.invokers.BaseInvoker
annotationFinder, handleException, isSkipExceptionAndSkip, log, runInvokedMethodListeners
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.testng.internal.invokers.ITestInvoker
getRunner, registerSkippedTestResult
-
-
-
-
Field Detail
-
invoker
private final ConfigInvoker invoker
-
holder
private final DataProviderHolder holder
-
m_classListeners
private final java.util.List<IClassListener> m_classListeners
-
m_skipFailedInvocationCounts
private final boolean m_skipFailedInvocationCounts
-
-
Constructor Detail
-
TestInvoker
public TestInvoker(ITestResultNotifier m_notifier, ITestContext m_testContext, SuiteRunState m_suiteState, IConfiguration m_configuration, java.util.Collection<IInvokedMethodListener> m_invokedMethodListeners, DataProviderHolder holder, java.util.List<IClassListener> m_classListeners, boolean m_skipFailedInvocationCounts, ConfigInvoker invoker, SuiteRunner suiteRunner)
-
-
Method Detail
-
getNotifier
public ITestResultNotifier getNotifier()
- Specified by:
getNotifier
in interfaceITestInvoker
-
invokeTestMethods
public java.util.List<ITestResult> invokeTestMethods(ITestNGMethod testMethod, ConfigurationGroupMethods groupMethods, java.lang.Object instance, ITestContext context)
- Specified by:
invokeTestMethods
in interfaceITestInvoker
-
invokeTestMethod
public ITestResult invokeTestMethod(TestMethodArguments arguments, XmlSuite suite, ITestInvoker.FailureContext failureContext)
invokeTestMethods() eventually converge here to invoke a single @Test method.This method is responsible for actually invoking the method. It decides if the invocation must be done:
- through an
IHookable
- directly (through reflection)
- in a separate thread (in case it needs to timeout)
This method is also responsible for invoking @BeforeGroup, @BeforeMethod, @AfterMethod, @AfterGroup if it is the case for the passed in @Test method.
- Specified by:
invokeTestMethod
in interfaceITestInvoker
- through an
-
retryFailed
public ITestInvoker.FailureContext retryFailed(TestMethodArguments arguments, java.util.List<ITestResult> result, int failureCount, ITestContext testContext)
- Specified by:
retryFailed
in interfaceITestInvoker
-
runTestResultListener
public void runTestResultListener(ITestResult tr)
- Specified by:
runTestResultListener
in interfaceITestInvoker
-
dataProviderListeners
private java.util.Collection<IDataProviderListener> dataProviderListeners()
-
buildDataProviderHolder
private DataProviderHolder buildDataProviderHolder()
-
checkDependencies
private java.lang.String checkDependencies(ITestNGMethod testMethod)
Checks to see of the test method has certain dependencies that prevents TestNG from executing it- Parameters:
testMethod
- test method being checked for- Returns:
- error message or null if dependencies have been run successfully
-
runWorkers
private java.util.List<ITestResult> runWorkers(ITestNGMethod testMethod, java.util.List<IWorker<ITestNGMethod>> workers, int threadPoolSize, ConfigurationGroupMethods groupMethods, 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.
-
failuresPresentInUpstreamDependency
private boolean failuresPresentInUpstreamDependency(ITestNGMethod testMethod, ITestNGMethod[] methods)
-
keepSameInstances
private java.util.Set<ITestResult> keepSameInstances(ITestNGMethod method, java.util.Set<ITestResult> results)
- Returns:
- the test results that apply to one of the instances of the testMethod.
-
invokePooledTestMethods
private java.util.List<ITestResult> invokePooledTestMethods(ITestNGMethod testMethod, java.util.Map<java.lang.String,java.lang.String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext)
Invokes a method that has a specified threadPoolSize.
-
collectResults
private void collectResults(ITestNGMethod testMethod, ITestResult result)
-
invokeListenersForSkippedTestResult
public void invokeListenersForSkippedTestResult(ITestResult r, IInvokedMethod invokedMethod)
- Specified by:
invokeListenersForSkippedTestResult
in interfaceITestInvoker
-
setTestStatus
private static void setTestStatus(ITestResult result, int status)
-
handleInvocationResult
private void handleInvocationResult(ITestNGMethod testMethod, ITestResult testResult, ITestInvoker.FailureContext failure, TestInvoker.StatusHolder holder, boolean willRetry)
-
shouldRetryTestMethod
private boolean shouldRetryTestMethod(ITestNGMethod testMethod, ITestResult testResult, ITestInvoker.FailureContext failure, TestInvoker.StatusHolder holder)
-
invokeMethod
private ITestResult invokeMethod(TestMethodArguments arguments, XmlSuite suite, ITestInvoker.FailureContext failureContext)
-
cleanInterruptStatus
private static void cleanInterruptStatus()
-
runAfterConfigurations
private void runAfterConfigurations(TestMethodArguments arguments, XmlSuite suite, TestResult testResult)
-
runAfterGroupsConfigurations
private void runAfterGroupsConfigurations(TestMethodArguments arguments)
-
runConfigMethods
private void runConfigMethods(TestMethodArguments arguments, XmlSuite suite, TestResult testResult, ITestNGMethod[] teardownConfigMethods)
-
registerSkippedTestResult
public ITestResult registerSkippedTestResult(ITestNGMethod testMethod, long start, java.lang.Throwable throwable, ITestResult source)
- Specified by:
registerSkippedTestResult
in interfaceITestInvoker
-
considerExceptions
private TestInvoker.StatusHolder considerExceptions(ITestNGMethod tm, ITestResult testResult, ExpectedExceptionsHolder exceptionsHolder, ITestInvoker.FailureContext failure)
-
updateStatusHolderAccordingToTestResult
private static void updateStatusHolderAccordingToTestResult(ITestResult testResult, TestInvoker.StatusHolder holder)
-
-