Package org.testng.internal.invokers
Class TestMethodWorker
java.lang.Object
org.testng.internal.invokers.TestMethodWorker
- All Implemented Interfaces:
Comparable<IWorker<ITestNGMethod>>,Runnable,IWorker<ITestNGMethod>
- Direct Known Subclasses:
SingleTestMethodWorker
FIXME: reduce contention when this class is used through parallel invocation due to
invocationCount and threadPoolSize by not invoking the @BeforeClass and @AfterClass which are
already invoked on the original method.
This class implements Runnable and will invoke the ITestMethod passed in its constructor on its run() method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate longprivate final ClassMethodMapprivate final IConfigInvokerprivate final ConfigurationGroupMethodsprivate final List<IClassListener> private final List<IMethodInstance> private final ITestContextprivate final ITestInvokerprivate final List<ITestResult> private long -
Constructor Summary
ConstructorsConstructorDescriptionTestMethodWorker(ITestInvoker testInvoker, IConfigInvoker configInvoker, List<IMethodInstance> testMethods, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, List<IClassListener> listeners) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanintcompareTo(IWorker<ITestNGMethod> other) booleanprivate booleanlongintThe priority of a worker is the priority of the first method it's going to run.getTasks()longRetrieves the maximum specified timeout of all ITestNGMethods to be run.protected intindexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods) private voidinvokeAfterClassConfigurations(ITestClass testClass, List<Object> invokeInstances) protected voidinvokeAfterClassMethods(ITestClass testClass, IMethodInstance mi) Invoke the @AfterClass methods if not done alreadyprotected voidinvokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi) Invoke the @BeforeClass methods if not done alreadyprivate voidinvokeListenersOnAfterClass(ITestClass testClass, List<IClassListener> listeners) protected voidinvokeTestMethods(ITestNGMethod tm, Object instance) voidrun()Run all the ITestNGMethods passed in through the constructor.voidsetThreadIdToRunOn(long threadIdToRunOn) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testng.thread.IWorker
getThreadIdToRunOn
-
Field Details
-
m_methodInstances
-
m_parameters
-
m_testResults
-
m_groupMethods
-
m_classMethodMap
-
m_testContext
-
m_listeners
-
currentThreadId
private long currentThreadId -
threadIdToRunOn
private long threadIdToRunOn -
completed
private boolean completed -
m_testInvoker
-
m_configInvoker
-
-
Constructor Details
-
TestMethodWorker
public TestMethodWorker(ITestInvoker testInvoker, IConfigInvoker configInvoker, List<IMethodInstance> testMethods, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, List<IClassListener> listeners)
-
-
Method Details
-
getTimeOut
public long getTimeOut()Retrieves the maximum specified timeout of all ITestNGMethods to be run.- Specified by:
getTimeOutin interfaceIWorker<ITestNGMethod>- Returns:
- the max timeout or 0 if no timeout was specified
-
toString
-
run
public void run()Run all the ITestNGMethods passed in through the constructor. -
doesTaskHavePreRequisites
private boolean doesTaskHavePreRequisites() -
invokeTestMethods
-
canInvokeBeforeClassMethods
private boolean canInvokeBeforeClassMethods() -
invokeBeforeClassMethods
Invoke the @BeforeClass methods if not done already -
invokeAfterClassMethods
Invoke the @AfterClass methods if not done already -
invokeAfterClassConfigurations
-
invokeListenersOnAfterClass
-
indexOf
-
getTestResults
-
getTasks
- Specified by:
getTasksin interfaceIWorker<ITestNGMethod>- Returns:
- list of tasks this worker is working on.
-
compareTo
- Specified by:
compareToin interfaceComparable<IWorker<ITestNGMethod>>
-
getPriority
public int getPriority()The priority of a worker is the priority of the first method it's going to run.- Specified by:
getPriorityin interfaceIWorker<ITestNGMethod>- Returns:
- the priority of this task.
-
getCurrentThreadId
public long getCurrentThreadId()- Specified by:
getCurrentThreadIdin interfaceIWorker<ITestNGMethod>
-
setThreadIdToRunOn
public void setThreadIdToRunOn(long threadIdToRunOn) - Specified by:
setThreadIdToRunOnin interfaceIWorker<ITestNGMethod>
-
completed
public boolean completed()- Specified by:
completedin interfaceIWorker<ITestNGMethod>
-