Class 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 Detail

      • m_methodInstances

        private final java.util.List<IMethodInstance> m_methodInstances
      • m_parameters

        private final java.util.Map<java.lang.String,​java.lang.String> m_parameters
      • m_testResults

        private final java.util.List<ITestResult> m_testResults
      • m_listeners

        private final java.util.List<IClassListener> m_listeners
      • currentThreadId

        private long currentThreadId
      • threadIdToRunOn

        private long threadIdToRunOn
      • completed

        private boolean completed
    • Method Detail

      • getTimeOut

        public long getTimeOut()
        Retrieves the maximum specified timeout of all ITestNGMethods to be run.
        Specified by:
        getTimeOut in interface IWorker<ITestNGMethod>
        Returns:
        the max timeout or 0 if no timeout was specified
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • run

        public void run()
        Run all the ITestNGMethods passed in through the constructor.
        Specified by:
        run in interface java.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
      • getTestResults

        public java.util.List<ITestResult> getTestResults()
      • 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 interface IWorker<ITestNGMethod>
        Returns:
        the priority of this task.