Class TestNGListener

java.lang.Object
com.shaft.listeners.TestNGListener
All Implemented Interfaces:
org.testng.IAlterSuiteListener, org.testng.IAnnotationTransformer, org.testng.IConfigurationListener, org.testng.IExecutionListener, org.testng.IInvokedMethodListener, org.testng.internal.IResultListener, org.testng.internal.IResultListener2, org.testng.ISuiteListener, org.testng.ITestListener, org.testng.ITestNGListener

public class TestNGListener extends Object implements org.testng.IAlterSuiteListener, org.testng.IAnnotationTransformer, org.testng.IExecutionListener, org.testng.ISuiteListener, org.testng.IInvokedMethodListener, org.testng.ITestListener, org.testng.internal.IResultListener2
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Supplier<com.epam.reportportal.testng.ITestNGService>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterInvocation(org.testng.IInvokedMethod iInvokedMethod, org.testng.ITestResult iTestResult, org.testng.ITestContext iTestContext)
    A listener that gets invoked after a method is invoked by TestNG.
    void
    alter(List<org.testng.xml.XmlSuite> suites)
    Implementations of this interface will gain access to the XmlSuite object and thus let users be able to alter a suite or a test based on their own needs.
    void
    beforeConfiguration(org.testng.ITestResult testResult)
     
    void
    beforeInvocation(org.testng.IInvokedMethod method, org.testng.ITestResult iTestResult, org.testng.ITestContext iTestContext)
    A listener that gets invoked before a method is invoked by TestNG.
    static void
     
     
    void
    onConfigurationFailure(org.testng.ITestResult testResult)
     
    void
    onConfigurationSkip(org.testng.ITestResult testResult)
     
    void
    onConfigurationSuccess(org.testng.ITestResult testResult)
     
    void
    gets invoked at the very last (after attachTestArtifacts generation phase), before TestNG exits the JVM.
    void
    gets invoked before TestNG proceeds with invoking any other listener.
    void
    onFinish(org.testng.ISuite suite)
     
    void
    onFinish(org.testng.ITestContext testContext)
     
    void
    onStart(org.testng.ISuite suite)
    This method is invoked before the SuiteRunner starts.
    void
    onStart(org.testng.ITestContext testContext)
     
    void
    onTestFailedButWithinSuccessPercentage(org.testng.ITestResult result)
     
    void
    onTestFailure(org.testng.ITestResult testResult)
     
    void
    onTestSkipped(org.testng.ITestResult testResult)
     
    void
    onTestStart(org.testng.ITestResult testResult)
     
    void
    onTestSuccess(org.testng.ITestResult testResult)
     
    void
    transform(org.testng.annotations.ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod)
    This method will be invoked by TestNG to give you a chance to modify a TestNG annotation read from your test classes.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.testng.IAnnotationTransformer

    transform, transform, transform, transform

    Methods inherited from interface org.testng.IConfigurationListener

    beforeConfiguration, onConfigurationFailure, onConfigurationSkip, onConfigurationSuccess

    Methods inherited from interface org.testng.IInvokedMethodListener

    afterInvocation, beforeInvocation

    Methods inherited from interface org.testng.ITestListener

    onTestFailedWithTimeout

    Methods inherited from interface org.testng.ITestNGListener

    isEnabled
  • Field Details

    • REPORT_PORTAL_SERVICE

      public static final Supplier<com.epam.reportportal.testng.ITestNGService> REPORT_PORTAL_SERVICE
  • Constructor Details

    • TestNGListener

      public TestNGListener()
  • Method Details

    • identifyRunType

      public static ProjectStructureManager.RunType identifyRunType()
    • engineSetup

      public static void engineSetup(ProjectStructureManager.RunType runType)
    • onExecutionStart

      public void onExecutionStart()
      gets invoked before TestNG proceeds with invoking any other listener.
      Specified by:
      onExecutionStart in interface org.testng.IExecutionListener
    • alter

      public void alter(List<org.testng.xml.XmlSuite> suites)
      Implementations of this interface will gain access to the XmlSuite object and thus let users be able to alter a suite or a test based on their own needs.
      Specified by:
      alter in interface org.testng.IAlterSuiteListener
      Parameters:
      suites - - The list of XmlSuites that are part of the current execution.
    • onStart

      public void onStart(org.testng.ISuite suite)
      This method is invoked before the SuiteRunner starts.
      Specified by:
      onStart in interface org.testng.ISuiteListener
      Parameters:
      suite - The suite
    • onFinish

      public void onFinish(org.testng.ISuite suite)
      Specified by:
      onFinish in interface org.testng.ISuiteListener
    • onStart

      public void onStart(org.testng.ITestContext testContext)
      Specified by:
      onStart in interface org.testng.ITestListener
    • onFinish

      public void onFinish(org.testng.ITestContext testContext)
      Specified by:
      onFinish in interface org.testng.ITestListener
    • beforeConfiguration

      public void beforeConfiguration(org.testng.ITestResult testResult)
      Specified by:
      beforeConfiguration in interface org.testng.IConfigurationListener
    • onConfigurationFailure

      public void onConfigurationFailure(org.testng.ITestResult testResult)
      Specified by:
      onConfigurationFailure in interface org.testng.IConfigurationListener
    • onConfigurationSuccess

      public void onConfigurationSuccess(org.testng.ITestResult testResult)
      Specified by:
      onConfigurationSuccess in interface org.testng.IConfigurationListener
    • onConfigurationSkip

      public void onConfigurationSkip(org.testng.ITestResult testResult)
      Specified by:
      onConfigurationSkip in interface org.testng.IConfigurationListener
    • onTestFailedButWithinSuccessPercentage

      public void onTestFailedButWithinSuccessPercentage(org.testng.ITestResult result)
      Specified by:
      onTestFailedButWithinSuccessPercentage in interface org.testng.ITestListener
    • transform

      public void transform(org.testng.annotations.ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod)
      This method will be invoked by TestNG to give you a chance to modify a TestNG annotation read from your test classes. You can change the values you need by calling any of the setters on the ITest interface.

      Note that only one of the three parameters testClass, testConstructor and testMethod will be non-null.

      Specified by:
      transform in interface org.testng.IAnnotationTransformer
      Parameters:
      annotation - The annotation that was read from your test class.
      testClass - If the annotation was found on a class, this parameter represents this class (null otherwise).
      testConstructor - If the annotation was found on a constructor, this parameter represents this constructor (null otherwise).
      testMethod - If the annotation was found on a method, this parameter represents this method (null otherwise).
    • beforeInvocation

      public void beforeInvocation(org.testng.IInvokedMethod method, org.testng.ITestResult iTestResult, org.testng.ITestContext iTestContext)
      A listener that gets invoked before a method is invoked by TestNG. This listener will be invoked for configuration and test methods irrespective of whether they pass/fail or get skipped. This listener invocation can be disabled for SKIPPED tests through one of the below mechanisms:
      • Command line parameter alwaysRunListeners
      • Build tool
      • Via TestNG.alwaysRunListeners(false)
      Specified by:
      beforeInvocation in interface org.testng.IInvokedMethodListener
    • afterInvocation

      public void afterInvocation(org.testng.IInvokedMethod iInvokedMethod, org.testng.ITestResult iTestResult, org.testng.ITestContext iTestContext)
      A listener that gets invoked after a method is invoked by TestNG. This listener will be invoked for configuration and test methods irrespective of whether they pass/fail or get skipped. This listener invocation can be disabled for SKIPPED tests through one of the below mechanisms:
      • Command line parameter alwaysRunListeners
      • Build tool
      • Via TestNG.alwaysRunListeners(false)
      Specified by:
      afterInvocation in interface org.testng.IInvokedMethodListener
    • onExecutionFinish

      public void onExecutionFinish()
      gets invoked at the very last (after attachTestArtifacts generation phase), before TestNG exits the JVM.
      Specified by:
      onExecutionFinish in interface org.testng.IExecutionListener
    • onTestStart

      public void onTestStart(org.testng.ITestResult testResult)
      Specified by:
      onTestStart in interface org.testng.ITestListener
    • onTestSuccess

      public void onTestSuccess(org.testng.ITestResult testResult)
      Specified by:
      onTestSuccess in interface org.testng.ITestListener
    • onTestFailure

      public void onTestFailure(org.testng.ITestResult testResult)
      Specified by:
      onTestFailure in interface org.testng.ITestListener
    • onTestSkipped

      public void onTestSkipped(org.testng.ITestResult testResult)
      Specified by:
      onTestSkipped in interface org.testng.ITestListener