Package org.testng.internal
Class TestMethodWorker
- java.lang.Object
-
- org.testng.internal.TestMethodWorker
-
- All Implemented Interfaces:
java.lang.Comparable<IWorker<ITestNGMethod>>,java.lang.Runnable,IWorker<ITestNGMethod>
- Direct Known Subclasses:
SingleTestMethodWorker
public class TestMethodWorker extends java.lang.Object implements IWorker<ITestNGMethod>
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
Fields Modifier and Type Field Description private booleancompletedprivate longcurrentThreadIdprivate ClassMethodMapm_classMethodMapprivate IConfigInvokerm_configInvokerprivate ConfigurationGroupMethodsm_groupMethodsprivate java.util.List<IClassListener>m_listenersprivate java.util.List<IMethodInstance>m_methodInstancesprivate java.util.Map<java.lang.String,java.lang.String>m_parametersprivate ITestContextm_testContextprivate ITestInvokerm_testInvokerprivate java.util.List<ITestResult>m_testResultsprivate longthreadIdToRunOn
-
Constructor Summary
Constructors Constructor Description TestMethodWorker(ITestInvoker testInvoker, IConfigInvoker configInvoker, java.util.List<IMethodInstance> testMethods, java.util.Map<java.lang.String,java.lang.String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, java.util.List<IClassListener> listeners)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleancanInvokeBeforeClassMethods()intcompareTo(IWorker<ITestNGMethod> other)booleancompleted()private booleandoesTaskHavePreRequistes()longgetCurrentThreadId()intgetPriority()The priority of a worker is the priority of the first method it's going to run.java.util.List<ITestNGMethod>getTasks()java.util.List<ITestResult>getTestResults()longgetTimeOut()Retrieves the maximum specified timeout of all ITestNGMethods to be run.protected intindexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods)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 alreadyprotected voidinvokeTestMethods(ITestNGMethod tm, java.lang.Object instance)voidrun()Run all the ITestNGMethods passed in through the constructor.voidsetThreadIdToRunOn(long threadIdToRunOn)java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.testng.thread.IWorker
getThreadIdToRunOn
-
-
-
-
Field Detail
-
m_methodInstances
private java.util.List<IMethodInstance> m_methodInstances
-
m_parameters
private final java.util.Map<java.lang.String,java.lang.String> m_parameters
-
m_testResults
private java.util.List<ITestResult> m_testResults
-
m_groupMethods
private final ConfigurationGroupMethods m_groupMethods
-
m_classMethodMap
private final ClassMethodMap m_classMethodMap
-
m_testContext
private final ITestContext m_testContext
-
m_listeners
private final java.util.List<IClassListener> m_listeners
-
currentThreadId
private long currentThreadId
-
threadIdToRunOn
private long threadIdToRunOn
-
completed
private boolean completed
-
m_testInvoker
private final ITestInvoker m_testInvoker
-
m_configInvoker
private final IConfigInvoker m_configInvoker
-
-
Constructor Detail
-
TestMethodWorker
public TestMethodWorker(ITestInvoker testInvoker, IConfigInvoker configInvoker, java.util.List<IMethodInstance> testMethods, java.util.Map<java.lang.String,java.lang.String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, java.util.List<IClassListener> listeners)
-
-
Method Detail
-
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
run
public void run()
Run all the ITestNGMethods passed in through the constructor.- Specified by:
runin interfacejava.lang.Runnable- See Also:
Runnable.run()
-
doesTaskHavePreRequistes
private boolean doesTaskHavePreRequistes()
-
invokeTestMethods
protected void invokeTestMethods(ITestNGMethod tm, java.lang.Object instance)
-
canInvokeBeforeClassMethods
private boolean canInvokeBeforeClassMethods()
-
invokeBeforeClassMethods
protected void invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi)
Invoke the @BeforeClass methods if not done already
-
invokeAfterClassMethods
protected void invokeAfterClassMethods(ITestClass testClass, IMethodInstance mi)
Invoke the @AfterClass methods if not done already
-
indexOf
protected int indexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods)
-
getTestResults
public java.util.List<ITestResult> getTestResults()
-
getTasks
public java.util.List<ITestNGMethod> getTasks()
- Specified by:
getTasksin interfaceIWorker<ITestNGMethod>- Returns:
- list of tasks this worker is working on.
-
compareTo
public int compareTo(@Nonnull IWorker<ITestNGMethod> other)- Specified by:
compareToin interfacejava.lang.Comparable<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>
-
-