Package org.testng

Class TestRunner

    • Field Detail

      • DEFAULT_PROP_OUTPUT_DIR

        private static final java.lang.String DEFAULT_PROP_OUTPUT_DIR
        See Also:
        Constant Field Values
      • LOGGER

        private static final Logger LOGGER
      • comparator

        private final java.util.Comparator<ITestNGMethod> comparator
      • m_suite

        private ISuite m_suite
      • m_xmlTest

        private XmlTest m_xmlTest
      • m_testName

        private java.lang.String m_testName
      • m_testClassesFromXml

        private java.util.List<XmlClass> m_testClassesFromXml
      • m_testListeners

        private final java.util.List<ITestListener> m_testListeners
        ITestListeners support.
      • m_startDate

        private java.util.Date m_startDate
      • m_endDate

        private java.util.Date m_endDate
      • m_classMap

        private final java.util.Map<java.lang.Class<?>,​ITestClass> m_classMap
        A map to keep track of Class <-> IClass.
      • m_outputDirectory

        private java.lang.String m_outputDirectory
        Where the reports will be created.
      • m_verbose

        private static int m_verbose
      • m_beforeSuiteMethods

        private ITestNGMethod[] m_beforeSuiteMethods
      • m_afterSuiteMethods

        private ITestNGMethod[] m_afterSuiteMethods
      • m_beforeXmlTestMethods

        private ITestNGMethod[] m_beforeXmlTestMethods
      • m_afterXmlTestMethods

        private ITestNGMethod[] m_afterXmlTestMethods
      • m_excludedMethods

        private final java.util.List<ITestNGMethod> m_excludedMethods
      • m_metaGroups

        private final java.util.Map<java.lang.String,​java.util.List<java.lang.String>> m_metaGroups
      • m_passedTests

        private final IResultMap m_passedTests
      • m_failedTests

        private final IResultMap m_failedTests
      • m_failedButWithinSuccessPercentageTests

        private final IResultMap m_failedButWithinSuccessPercentageTests
      • m_skippedTests

        private final IResultMap m_skippedTests
      • m_runInfo

        private final RunInfo m_runInfo
      • m_host

        private java.lang.String m_host
      • m_allJunitTestMethods

        private ITestNGMethod[] m_allJunitTestMethods
      • m_passedConfigurations

        private final IResultMap m_passedConfigurations
      • m_skippedConfigurations

        private final IResultMap m_skippedConfigurations
      • m_failedConfigurations

        private final IResultMap m_failedConfigurations
      • m_configsToBeInvoked

        private final IResultMap m_configsToBeInvoked
      • m_guiceModules

        private final ListMultiMap<java.lang.Class<? extends com.google.inject.Module>,​com.google.inject.Module> m_guiceModules
      • m_injectors

        private final java.util.Map<java.util.List<com.google.inject.Module>,​com.google.inject.Injector> m_injectors
    • Method Detail

      • getAllPackages

        private java.util.List<XmlPackage> getAllPackages()
        Returns all packages to use for the current test. This includes the test from the test suite. Never returns null.
      • getInvoker

        public IInvoker getInvoker()
      • getBeforeSuiteMethods

        public ITestNGMethod[] getBeforeSuiteMethods()
      • getAfterSuiteMethods

        public ITestNGMethod[] getAfterSuiteMethods()
      • getBeforeTestConfigurationMethods

        public ITestNGMethod[] getBeforeTestConfigurationMethods()
      • getAfterTestConfigurationMethods

        public ITestNGMethod[] getAfterTestConfigurationMethods()
      • init

        private void init()
      • initListeners

        private void initListeners()
      • initMetaGroups

        private void initMetaGroups​(XmlTest xmlTest)
        Initialize meta groups
      • initRunInfo

        private void initRunInfo​(XmlTest xmlTest)
      • initMethods

        private void initMethods()
      • computeAndGetAllTestMethods

        private ITestNGMethod[] computeAndGetAllTestMethods()
      • getTestClasses

        public java.util.Collection<ITestClass> getTestClasses()
      • setTestName

        public void setTestName​(java.lang.String name)
      • setOutputDirectory

        public void setOutputDirectory​(java.lang.String od)
      • addMetaGroup

        private void addMetaGroup​(java.lang.String name,
                                  java.util.List<java.lang.String> groupNames)
      • createGroups

        private java.util.Map<java.lang.String,​java.lang.String> createGroups​(java.util.List<java.lang.String> groups)
      • run

        public void run()
        The main entry method for TestRunner.

        This is where all the hard work is done: - Invoke configuration methods - Invoke test methods - Catch exceptions - Collect results - Invoke listeners - etc...

      • forgetHeavyReferencesIfNeeded

        private void forgetHeavyReferencesIfNeeded()
      • beforeRun

        private void beforeRun()
        Before run preparements.
      • invokeTestConfigurations

        private void invokeTestConfigurations​(ITestNGMethod[] testConfigurationMethods)
      • privateRunJUnit

        private void privateRunJUnit()
      • newComparator

        private static java.util.Comparator<ITestNGMethod> newComparator​(boolean needPrioritySort)
      • sortOnPriority

        private boolean sortOnPriority​(ITestNGMethod[] interceptedOrder)
      • newQueue

        private static java.util.concurrent.BlockingQueue<java.lang.Runnable> newQueue​(boolean needPrioritySort)
      • privateRun

        private void privateRun​(XmlTest xmlTest)
        Main method that create a graph of methods and then pass it to the graph executor to run them.
      • intercept

        private ITestNGMethod[] intercept​(ITestNGMethod[] methods)
        Apply the method interceptor (if applicable) to the list of methods.
      • createWorkers

        public java.util.List<IWorker<ITestNGMethod>> createWorkers​(java.util.List<ITestNGMethod> methods)
        Create a list of workers to run the methods passed in parameter. Each test method is run in its own worker except in the following cases: - The method belongs to a class that has @Test(sequential=true) - The parallel attribute is set to "classes" In both these cases, all the methods belonging to that class will then be put in the same worker in order to run in the same thread.
        Specified by:
        createWorkers in interface IThreadWorkerFactory<ITestNGMethod>
        Parameters:
        methods - tasks that need to be executed
        Returns:
        list of workers
      • runJUnitWorkers

        private void runJUnitWorkers​(java.util.List<? extends IWorker<ITestNGMethod>> workers)
      • afterRun

        private void afterRun()
      • logStart

        private void logStart()
        Logs the beginning of the beforeRun() .
      • fireEvent

        private void fireEvent​(boolean isStart)
        Trigger the start/finish event.
        Parameters:
        isStart - true if the event is for start, false if the event is for finish
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface ITestContext
        Returns:
        The name of this test.
      • getStartDate

        public java.util.Date getStartDate()
        Specified by:
        getStartDate in interface ITestContext
        Returns:
        Returns the startDate.
      • getEndDate

        public java.util.Date getEndDate()
        Specified by:
        getEndDate in interface ITestContext
        Returns:
        Returns the endDate.
      • getIncludedGroups

        public java.lang.String[] getIncludedGroups()
        Specified by:
        getIncludedGroups in interface ITestContext
        Returns:
        All the groups that are included for this test run.
      • getExcludedGroups

        public java.lang.String[] getExcludedGroups()
        Specified by:
        getExcludedGroups in interface ITestContext
        Returns:
        All the groups that are excluded for this test run.
      • getOutputDirectory

        public java.lang.String getOutputDirectory()
        Specified by:
        getOutputDirectory in interface ITestContext
        Returns:
        Where the reports will be generated.
      • getHost

        public java.lang.String getHost()
        Specified by:
        getHost in interface ITestContext
        Returns:
        The host where this test was run, or null if it was run locally. The returned string has the form: host:port
      • logFailedTest

        private void logFailedTest​(ITestResult tr,
                                   boolean withinSuccessPercentage)
      • log

        private static void log​(java.lang.String s)
      • getVerbose

        public static int getVerbose()
      • setVerbose

        public void setVerbose​(int n)
      • addTestListener

        void addTestListener​(ITestListener listener)
      • dumpInvokedMethods

        private void dumpInvokedMethods()
      • addMethodInterceptor

        void addMethodInterceptor​(IMethodInterceptor methodInterceptor)
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Specified by:
        getAttribute in interface IAttributes
        Parameters:
        name - The name of the attribute to return
        Returns:
        The attribute
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.Object value)
        Description copied from interface: IAttributes
        Set a custom attribute.
        Specified by:
        setAttribute in interface IAttributes
        Parameters:
        name - The attribute name
        value - The attribute value
      • getAttributeNames

        public java.util.Set<java.lang.String> getAttributeNames()
        Specified by:
        getAttributeNames in interface IAttributes
        Returns:
        all the attributes names.
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String name)
        Description copied from interface: IAttributes
        Remove the attribute
        Specified by:
        removeAttribute in interface IAttributes
        Parameters:
        name - The attribute name
        Returns:
        the attribute value if found, null otherwise
      • getGuiceModules

        public java.util.List<com.google.inject.Module> getGuiceModules​(java.lang.Class<? extends com.google.inject.Module> cls)
        Description copied from interface: ITestContext
        This method stands deprecated as of TestNG 7.3.0
        Specified by:
        getGuiceModules in interface ITestContext
      • getAllGuiceModules

        public java.util.List<com.google.inject.Module> getAllGuiceModules()
        Description copied from interface: ITestContext
        This method stands deprecated as of TestNG 7.3.0
        Specified by:
        getAllGuiceModules in interface ITestContext
      • addGuiceModule

        public void addGuiceModule​(com.google.inject.Module module)
        Description copied from interface: ITestContext
        This method stands deprecated as of TestNG 7.3.0
        Specified by:
        addGuiceModule in interface ITestContext
      • getInjector

        public com.google.inject.Injector getInjector​(java.util.List<com.google.inject.Module> moduleInstances)
        Description copied from interface: ITestContext
        This method stands deprecated as of TestNG 7.3.0
        Specified by:
        getInjector in interface ITestContext
      • getInjector

        public com.google.inject.Injector getInjector​(IClass iClass)
        Description copied from interface: ITestContext
        This method stands deprecated as of TestNG 7.3.0
        Specified by:
        getInjector in interface ITestContext
      • addInjector

        public void addInjector​(java.util.List<com.google.inject.Module> moduleInstances,
                                com.google.inject.Injector injector)
        Description copied from interface: ITestContext
        This method stands deprecated as of TestNG 7.3.0
        Specified by:
        addInjector in interface ITestContext
      • hasNoGuiceAnnotations

        private static boolean hasNoGuiceAnnotations​(IClass iClass)