Class TestNGListener

java.lang.Object
com.shaft.listeners.TestNGListener
All Implemented Interfaces:
org.testng.IAlterSuiteListener, org.testng.IAnnotationTransformer, org.testng.IExecutionListener, org.testng.IInvokedMethodListener, 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
  • 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
    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
    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
    onStart(org.testng.ISuite suite)
    This method is invoked before the SuiteRunner starts.
    void
    onTestFailure(org.testng.ITestResult result)
     
    void
    onTestSkipped(org.testng.ITestResult result)
     
    void
    onTestSuccess(org.testng.ITestResult result)
     
    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.IInvokedMethodListener

    afterInvocation, beforeInvocation

    Methods inherited from interface org.testng.ISuiteListener

    onFinish

    Methods inherited from interface org.testng.ITestListener

    onFinish, onStart, onTestFailedButWithinSuccessPercentage, onTestFailedWithTimeout, onTestStart

    Methods inherited from interface org.testng.ITestNGListener

    isEnabled
  • 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
    • 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
    • onTestSuccess

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

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

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