Package com.shaft.listeners
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Implementations of this interface will gain access to theXmlSuite
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
-
engineSetup
-
onExecutionStart
public void onExecutionStart()gets invoked before TestNG proceeds with invoking any other listener.- Specified by:
onExecutionStart
in interfaceorg.testng.IExecutionListener
-
alter
Implementations of this interface will gain access to theXmlSuite
object and thus let users be able to alter a suite or a test based on their own needs.- Specified by:
alter
in interfaceorg.testng.IAlterSuiteListener
- Parameters:
suites
- - The list ofXmlSuite
s 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 interfaceorg.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 interfaceorg.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 interfaceorg.testng.IInvokedMethodListener
- Command line parameter
-
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 interfaceorg.testng.IInvokedMethodListener
- Command line parameter
-
onExecutionFinish
public void onExecutionFinish()gets invoked at the very last (after attachTestArtifacts generation phase), before TestNG exits the JVM.- Specified by:
onExecutionFinish
in interfaceorg.testng.IExecutionListener
-
onTestSuccess
public void onTestSuccess(org.testng.ITestResult result) - Specified by:
onTestSuccess
in interfaceorg.testng.ITestListener
-
onTestFailure
public void onTestFailure(org.testng.ITestResult result) - Specified by:
onTestFailure
in interfaceorg.testng.ITestListener
-
onTestSkipped
public void onTestSkipped(org.testng.ITestResult result) - Specified by:
onTestSkipped
in interfaceorg.testng.ITestListener
-