Package org.testng

Class TestListenerAdapter

  • All Implemented Interfaces:
    IConfigurationListener, org.testng.internal.IResultListener, org.testng.internal.IResultListener2, ITestListener, ITestNGListener

    public class TestListenerAdapter
    extends java.lang.Object
    implements org.testng.internal.IResultListener2
    A simple ITestListener adapter that stores all the tests that were run. You can retrieve these results with the following methods: getPassedTests() getFailedTests() getSkippedTests()

    If you extend this class in order to override any of these methods, remember to call their super equivalent if you want this list of tests to be maintained.

    • Constructor Detail

      • TestListenerAdapter

        public TestListenerAdapter()
    • Method Detail

      • onTestFailedWithTimeout

        public void onTestFailedWithTimeout​(ITestResult tr)
        Description copied from interface: ITestListener
        Invoked each time a test fails due to a timeout.
        Specified by:
        onTestFailedWithTimeout in interface ITestListener
        Parameters:
        tr - ITestResult containing information about the run test
      • getAllTestMethods

        protected ITestNGMethod[] getAllTestMethods()
      • onStart

        public void onStart​(ITestContext testContext)
        Description copied from interface: ITestListener
        Invoked before running all the test methods belonging to the classes inside the <test> tag and calling all their Configuration methods.
        Specified by:
        onStart in interface ITestListener
        Parameters:
        testContext - The test context
      • onFinish

        public void onFinish​(ITestContext testContext)
        Description copied from interface: ITestListener
        Invoked after all the test methods belonging to the classes inside the <test> tag have run and all their Configuration methods have been called.
        Specified by:
        onFinish in interface ITestListener
        Parameters:
        testContext - The test context
      • getFailedButWithinSuccessPercentageTests

        public java.util.List<ITestResult> getFailedButWithinSuccessPercentageTests()
        Returns:
        Returns the failedButWithinSuccessPercentageTests.
      • getFailedTests

        public java.util.List<ITestResult> getFailedTests()
        Returns:
        Returns the failedTests.
      • getPassedTests

        public java.util.List<ITestResult> getPassedTests()
        Returns:
        Returns the passedTests.
      • getSkippedTests

        public java.util.List<ITestResult> getSkippedTests()
        Returns:
        Returns the skippedTests.
      • getTimedoutTests

        public java.util.Collection<ITestResult> getTimedoutTests()
        Returns:
        Returns the tests that failed due to a timeout
      • setAllTestMethods

        public void setAllTestMethods​(java.util.List<ITestNGMethod> allTestMethods)
        Parameters:
        allTestMethods - The allTestMethods to set.
      • setFailedButWithinSuccessPercentageTests

        public void setFailedButWithinSuccessPercentageTests​(java.util.List<ITestResult> failedButWithinSuccessPercentageTests)
        Parameters:
        failedButWithinSuccessPercentageTests - The failedButWithinSuccessPercentageTests to set.
      • setFailedTests

        public void setFailedTests​(java.util.List<ITestResult> failedTests)
        Parameters:
        failedTests - The failedTests to set.
      • setPassedTests

        public void setPassedTests​(java.util.List<ITestResult> passedTests)
        Parameters:
        passedTests - The passedTests to set.
      • setSkippedTests

        public void setSkippedTests​(java.util.List<ITestResult> skippedTests)
        Parameters:
        skippedTests - The skippedTests to set.
      • onTestStart

        public void onTestStart​(ITestResult result)
        Description copied from interface: ITestListener
        Invoked each time before a test will be invoked. The ITestResult is only partially filled with the references to class, method, start millis and status.
        Specified by:
        onTestStart in interface ITestListener
        Parameters:
        result - the partially filled ITestResult
        See Also:
        ITestResult.STARTED
      • getTestContexts

        public java.util.List<ITestContext> getTestContexts()
      • getConfigurationFailures

        public java.util.List<ITestResult> getConfigurationFailures()
      • getConfigurationSkips

        public java.util.List<ITestResult> getConfigurationSkips()
      • toString

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