Package org.testng.internal.invokers
Class TestInvoker
java.lang.Object
org.testng.internal.invokers.BaseInvoker
org.testng.internal.invokers.TestInvoker
- All Implemented Interfaces:
ITestInvoker
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate static classNested classes/interfaces inherited from interface org.testng.internal.invokers.ITestInvoker
ITestInvoker.FailureContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DataProviderHolderprivate final ConfigInvokerprivate final List<IClassListener> private final booleanFields inherited from class org.testng.internal.invokers.BaseInvoker
m_classInvocationResults, m_configuration, m_notifier, m_suiteState, m_testContext, NULL_OBJECT -
Constructor Summary
ConstructorsConstructorDescriptionTestInvoker(ITestResultNotifier m_notifier, ITestContext m_testContext, SuiteRunState m_suiteState, IConfiguration m_configuration, Collection<IInvokedMethodListener> m_invokedMethodListeners, DataProviderHolder holder, List<IClassListener> m_classListeners, boolean m_skipFailedInvocationCounts, ConfigInvoker invoker, SuiteRunner suiteRunner) -
Method Summary
Modifier and TypeMethodDescriptionprivate DataProviderHolderprivate StringcheckDependencies(ITestNGMethod testMethod) Checks to see of the test method has certain dependencies that prevents TestNG from executing itprivate static voidprivate voidcollectResults(ITestNGMethod testMethod, ITestResult result) private TestInvoker.StatusHolderconsiderExceptions(ITestNGMethod tm, ITestResult testResult, ExpectedExceptionsHolder exceptionsHolder, ITestInvoker.FailureContext failure) private Collection<IDataProviderListener> private booleanfailuresPresentInUpstreamDependency(ITestNGMethod testMethod, ITestNGMethod[] methods) private voidhandleInvocationResult(ITestNGMethod testMethod, ITestResult testResult, ITestInvoker.FailureContext failure, TestInvoker.StatusHolder holder, boolean willRetry) voidinvokeListenersForSkippedTestResult(ITestResult r, IInvokedMethod invokedMethod) private ITestResultinvokeMethod(TestMethodArguments arguments, XmlSuite suite, ITestInvoker.FailureContext failureContext) private List<ITestResult> invokePooledTestMethods(ITestNGMethod testMethod, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext) Invokes a method that has a specified threadPoolSize.invokeTestMethod(TestMethodArguments arguments, XmlSuite suite, ITestInvoker.FailureContext failureContext) invokeTestMethods() eventually converge here to invoke a single @Test method.invokeTestMethods(ITestNGMethod testMethod, ConfigurationGroupMethods groupMethods, Object instance, ITestContext context) private Set<ITestResult> keepSameInstances(ITestNGMethod method, Set<ITestResult> results) registerSkippedTestResult(ITestNGMethod testMethod, long start, Throwable throwable, ITestResult source) retryFailed(TestMethodArguments arguments, List<ITestResult> result, int failureCount, ITestContext testContext) private voidrunAfterConfigurations(TestMethodArguments arguments, XmlSuite suite, TestResult testResult) private voidrunAfterGroupsConfigurations(TestMethodArguments arguments) private voidrunConfigMethods(TestMethodArguments arguments, XmlSuite suite, TestResult testResult, ITestNGMethod[] teardownConfigMethods) voidprivate List<ITestResult> runWorkers(ITestNGMethod testMethod, List<IWorker<ITestNGMethod>> workers, int threadPoolSize, ConfigurationGroupMethods groupMethods, Map<String, 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 voidsetTestStatus(ITestResult result, int status) private booleanshouldRetryTestMethod(ITestNGMethod testMethod, ITestResult testResult, ITestInvoker.FailureContext failure, TestInvoker.StatusHolder holder) private static voidupdateStatusHolderAccordingToTestResult(ITestResult testResult, TestInvoker.StatusHolder holder) Methods inherited from class org.testng.internal.invokers.BaseInvoker
annotationFinder, handleException, isSkipExceptionAndSkip, log, runInvokedMethodListenersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.testng.internal.invokers.ITestInvoker
getRunner, registerSkippedTestResult
-
Field Details
-
invoker
-
holder
-
m_classListeners
-
m_skipFailedInvocationCounts
private final boolean m_skipFailedInvocationCounts
-
-
Constructor Details
-
TestInvoker
public TestInvoker(ITestResultNotifier m_notifier, ITestContext m_testContext, SuiteRunState m_suiteState, IConfiguration m_configuration, Collection<IInvokedMethodListener> m_invokedMethodListeners, DataProviderHolder holder, List<IClassListener> m_classListeners, boolean m_skipFailedInvocationCounts, ConfigInvoker invoker, SuiteRunner suiteRunner)
-
-
Method Details
-
getNotifier
- Specified by:
getNotifierin interfaceITestInvoker
-
invokeTestMethods
public List<ITestResult> invokeTestMethods(ITestNGMethod testMethod, ConfigurationGroupMethods groupMethods, Object instance, ITestContext context) - Specified by:
invokeTestMethodsin 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:
invokeTestMethodin interfaceITestInvoker
- through an
-
retryFailed
public ITestInvoker.FailureContext retryFailed(TestMethodArguments arguments, List<ITestResult> result, int failureCount, ITestContext testContext) - Specified by:
retryFailedin interfaceITestInvoker
-
runTestResultListener
- Specified by:
runTestResultListenerin interfaceITestInvoker
-
dataProviderListeners
-
buildDataProviderHolder
-
checkDependencies
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 List<ITestResult> runWorkers(ITestNGMethod testMethod, List<IWorker<ITestNGMethod>> workers, int threadPoolSize, ConfigurationGroupMethods groupMethods, Map<String, 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
- Returns:
- the test results that apply to one of the instances of the testMethod.
-
invokePooledTestMethods
private List<ITestResult> invokePooledTestMethods(ITestNGMethod testMethod, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ITestContext testContext) Invokes a method that has a specified threadPoolSize. -
collectResults
-
invokeListenersForSkippedTestResult
- Specified by:
invokeListenersForSkippedTestResultin interfaceITestInvoker
-
setTestStatus
-
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
-
runConfigMethods
private void runConfigMethods(TestMethodArguments arguments, XmlSuite suite, TestResult testResult, ITestNGMethod[] teardownConfigMethods) -
registerSkippedTestResult
public ITestResult registerSkippedTestResult(ITestNGMethod testMethod, long start, Throwable throwable, ITestResult source) - Specified by:
registerSkippedTestResultin 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)
-