Top Description Fields Constructors Methods
org.testng.internal.invokers

public Class TestMethodWorker

Additional top-level class in compilation unit: SingleTestMethodWorker.

extends Object
implements IWorker<ITestNGMethod>
Class Inheritance
All Implemented Interfaces
org.testng.thread.IWorker, java.lang.Comparable, java.lang.Runnable
Known Direct Subclasses
org.testng.internal.invokers.SingleTestMethodWorker
Static Imports
org.testng.ListenerComparator.sort

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

Modifier and TypeField and Description
private boolean
private long
private static final KeyAwareAutoCloseableLock
private final ClassMethodMap
private final IConfigInvoker
private final ConfigurationGroupMethods
private final List<IClassListener>
private final List<IMethodInstance>
private final Map<String, String>
private final ITestContext
private final ITestInvoker
private final List<ITestResult>
private long

Constructor Summary

AccessConstructor and Description
public
TestMethodWorker(ITestInvoker testInvoker, IConfigInvoker configInvoker, List<IMethodInstance> testMethods, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, List<IClassListener> listeners)

Method Summary

Modifier and TypeMethod and Description
private boolean
public int
compareTo(IWorker<ITestNGMethod>
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.
public boolean
private boolean
public long
public int
getPriority()

Implements org.testng.thread.IWorker.getPriority.

The priority of a worker is the priority of the first method it's going to run.
public List<ITestNGMethod>
public List<ITestResult>
public long

Returns:

the max timeout or 0 if no timeout was specified
getTimeOut
()

Implements org.testng.thread.IWorker.getTimeOut.

Retrieves the maximum specified timeout of all ITestNGMethods to be run.
protected int
indexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods)

private void
protected void
invokeAfterClassMethods(ITestClass testClass, IMethodInstance mi)

Invoke the @AfterClass methods if not done already

protected void
invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi)

Invoke the @BeforeClass methods if not done already

private void
protected void
public void
run()

Implements java.lang.Runnable.run.

Run all the ITestNGMethods passed in through the constructor.
public void
setThreadIdToRunOn(long threadIdToRunOn)

Overrides default org.testng.thread.IWorker.setThreadIdToRunOn.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

completedback to summary
private boolean completed
currentThreadIdback to summary
private long currentThreadId
lockback to summary
private static final KeyAwareAutoCloseableLock lock
m_classMethodMapback to summary
private final ClassMethodMap m_classMethodMap
m_configInvokerback to summary
private final IConfigInvoker m_configInvoker
m_groupMethodsback to summary
private final ConfigurationGroupMethods m_groupMethods
m_listenersback to summary
private final List<IClassListener> m_listeners
m_methodInstancesback to summary
private final List<IMethodInstance> m_methodInstances
m_parametersback to summary
private final Map<String, String> m_parameters
m_testContextback to summary
private final ITestContext m_testContext
m_testInvokerback to summary
private final ITestInvoker m_testInvoker
m_testResultsback to summary
private final List<ITestResult> m_testResults
threadIdToRunOnback to summary
private long threadIdToRunOn

Constructor Detail

TestMethodWorkerback to summary
public TestMethodWorker(ITestInvoker testInvoker, IConfigInvoker configInvoker, List<IMethodInstance> testMethods, Map<String, String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, List<IClassListener> listeners)

Method Detail

canInvokeBeforeClassMethodsback to summary
private boolean canInvokeBeforeClassMethods()
compareToback to summary
public int compareTo(IWorker<ITestNGMethod> other)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
other:IWorker<ITestNGMethod>

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
completedback to summary
public boolean completed()

Overrides default org.testng.thread.IWorker.completed.

Annotations
@Override
doesTaskHavePreRequisitesback to summary
private boolean doesTaskHavePreRequisites()
getCurrentThreadIdback to summary
public long getCurrentThreadId()

Overrides default org.testng.thread.IWorker.getCurrentThreadId.

Annotations
@Override
getPriorityback to summary
public int getPriority()

Implements org.testng.thread.IWorker.getPriority.

The priority of a worker is the priority of the first method it's going to run.

Returns:int

Doc from org.testng.thread.IWorker.getPriority.

the priority of this task.

Annotations
@Override
getTasksback to summary
public List<ITestNGMethod> getTasks()

Implements org.testng.thread.IWorker.getTasks.

Returns:List<ITestNGMethod>

Doc from org.testng.thread.IWorker.getTasks.

list of tasks this worker is working on.

Annotations
@Override
getTestResultsback to summary
public List<ITestResult> getTestResults()
getTimeOutback to summary
public long getTimeOut()

Implements org.testng.thread.IWorker.getTimeOut.

Retrieves the maximum specified timeout of all ITestNGMethods to be run.

Returns:long

the max timeout or 0 if no timeout was specified

Annotations
@Override
indexOfback to summary
protected int indexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods)
invokeAfterClassConfigurationsback to summary
private void invokeAfterClassConfigurations(ITestClass testClass, List<Object> invokeInstances)
invokeAfterClassMethodsback to summary
protected void invokeAfterClassMethods(ITestClass testClass, IMethodInstance mi)

Invoke the @AfterClass methods if not done already

invokeBeforeClassMethodsback to summary
protected void invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi)

Invoke the @BeforeClass methods if not done already

invokeListenersOnAfterClassback to summary
private void invokeListenersOnAfterClass(ITestClass testClass, List<IClassListener> listeners)
invokeTestMethodsback to summary
protected void invokeTestMethods(ITestNGMethod tm, Object instance)
runback to summary
public void run()

Implements java.lang.Runnable.run.

Run all the ITestNGMethods passed in through the constructor.

Annotations
@Override
See Also
java.lang.Runnable#run()
setThreadIdToRunOnback to summary
public void setThreadIdToRunOn(long threadIdToRunOn)

Overrides default org.testng.thread.IWorker.setThreadIdToRunOn.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override