Package org.testng.internal
Class TestMethodWorker
- java.lang.Object
-
- org.testng.internal.TestMethodWorker
-
- All Implemented Interfaces:
Comparable<IWorker<ITestNGMethod>>
,Runnable
,IWorker<ITestNGMethod>
public class TestMethodWorker extends 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.
-
-
Constructor Summary
Constructors Constructor Description TestMethodWorker(IInvoker invoker, List<IMethodInstance> testMethods, XmlSuite suite, Map<String,String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, List<IClassListener> listeners)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(IWorker<ITestNGMethod> other)
int
getPriority()
The priority of a worker is the priority of the first method it's going to run.List<ITestNGMethod>
getTasks()
List<ITestResult>
getTestResults()
long
getTimeOut()
Retrieves the maximum specified timeout of all ITestNGMethods to be run.protected int
indexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods)
protected void
invokeAfterClassMethods(ITestClass testClass, IMethodInstance mi)
Invoke the @AfterClass methods if not done alreadyprotected void
invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi)
Invoke the @BeforeClass methods if not done alreadyprotected void
invokeTestMethods(ITestNGMethod tm, Object instance, ITestContext testContext)
void
run()
Run all the ITestNGMethods passed in through the constructor.String
toString()
-
-
-
Constructor Detail
-
TestMethodWorker
public TestMethodWorker(IInvoker invoker, List<IMethodInstance> testMethods, XmlSuite suite, Map<String,String> parameters, ConfigurationGroupMethods groupMethods, ClassMethodMap classMethodMap, ITestContext testContext, List<IClassListener> listeners)
-
-
Method Detail
-
getTimeOut
public long getTimeOut()
Retrieves the maximum specified timeout of all ITestNGMethods to be run.- Specified by:
getTimeOut
in interfaceIWorker<ITestNGMethod>
- Returns:
- the max timeout or 0 if no timeout was specified
-
run
public void run()
Run all the ITestNGMethods passed in through the constructor.- Specified by:
run
in interfaceRunnable
- See Also:
Runnable.run()
-
invokeTestMethods
protected void invokeTestMethods(ITestNGMethod tm, Object instance, ITestContext testContext)
-
invokeBeforeClassMethods
protected void invokeBeforeClassMethods(ITestClass testClass, IMethodInstance mi)
Invoke the @BeforeClass methods if not done already- Parameters:
testClass
-mi
-
-
invokeAfterClassMethods
protected void invokeAfterClassMethods(ITestClass testClass, IMethodInstance mi)
Invoke the @AfterClass methods if not done already- Parameters:
testClass
-mi
-
-
indexOf
protected int indexOf(ITestNGMethod tm, ITestNGMethod[] allTestMethods)
-
getTestResults
public List<ITestResult> getTestResults()
-
getTasks
public List<ITestNGMethod> getTasks()
- Specified by:
getTasks
in interfaceIWorker<ITestNGMethod>
- Returns:
- list of tasks this worker is working on.
-
compareTo
public int compareTo(IWorker<ITestNGMethod> other)
- Specified by:
compareTo
in 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:
getPriority
in interfaceIWorker<ITestNGMethod>
- Returns:
- the priority of this task.
-
-