Class AllureTestNg

java.lang.Object
io.qameta.allure.testng.AllureTestNg
All Implemented Interfaces:
org.testng.IConfigurationListener, org.testng.IDataProviderListener, org.testng.IInvokedMethodListener, org.testng.IMethodInterceptor, org.testng.ISuiteListener, org.testng.ITestListener, org.testng.ITestNGListener

public class AllureTestNg extends Object implements org.testng.ISuiteListener, org.testng.ITestListener, org.testng.IInvokedMethodListener, org.testng.IConfigurationListener, org.testng.IMethodInterceptor, org.testng.IDataProviderListener
Reports TestNG execution to Allure.

Register this listener with TestNG to translate suites, test contexts, classes, configuration methods, data providers, and test methods into Allure scopes, fixtures, and test results. It also applies Allure test plan filtering when a plan is configured.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
    AllureTestNg(io.qameta.allure.AllureLifecycle lifecycle)
     
    AllureTestNg(io.qameta.allure.AllureLifecycle lifecycle, AllureTestNgTestFilter testFilter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterDataProviderExecution(org.testng.IDataProviderMethod dataProviderMethod, org.testng.ITestNGMethod method, org.testng.ITestContext iTestContext)
     
    void
    afterInvocation(org.testng.IInvokedMethod method, org.testng.ITestResult testResult)
     
    void
    beforeDataProviderExecution(org.testng.IDataProviderMethod dataProviderMethod, org.testng.ITestNGMethod method, org.testng.ITestContext iTestContext)
     
    void
    beforeInvocation(org.testng.IInvokedMethod method, org.testng.ITestResult testResult)
     
    protected void
    createFakeResult(org.testng.ITestContext context, org.testng.ITestNGMethod method)
     
    io.qameta.allure.AllureLifecycle
     
    protected io.qameta.allure.model.Status
    getStatus(Throwable throwable)
     
    List<org.testng.IMethodInstance>
    intercept(List<org.testng.IMethodInstance> methods, org.testng.ITestContext context)
     
    void
    onConfigurationFailure(org.testng.ITestResult itr)
    Reports a failed configuration method as a run-level error rather than as a test result.
    void
    onConfigurationSkip(org.testng.ITestResult itr)
     
    void
    onConfigurationSuccess(org.testng.ITestResult itr)
     
    void
    onDataProviderFailure(org.testng.ITestNGMethod method, org.testng.ITestContext ctx, RuntimeException t)
     
    void
    onFinish(org.testng.ISuite suite)
     
    void
    onFinish(org.testng.ITestContext context)
     
    void
    onStart(org.testng.ISuite suite)
     
    void
    onStart(org.testng.ITestContext context)
     
    void
    onTestFailedButWithinSuccessPercentage(org.testng.ITestResult result)
     
    void
    onTestFailure(org.testng.ITestResult result)
     
    void
    onTestSkipped(org.testng.ITestResult result)
     
    void
    onTestStart(org.testng.ITestResult testResult)
     
    void
    onTestSuccess(org.testng.ITestResult testResult)
     
    protected boolean
    shouldSkipReportingFor(org.testng.ITestResult testResult)
     
    protected void
    startTest(org.testng.ITestContext context, org.testng.ITestNGMethod method, org.testng.IClass iClass, Object[] params, String parentUuid, String uuid)
     
    protected void
    startTest(org.testng.ITestResult testResult, String parentUuid, String uuid)
     
    protected void
    stopTest(String uuid, Throwable throwable, io.qameta.allure.model.Status status)
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.testng.IConfigurationListener

    beforeConfiguration, 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
  • Constructor Details

    • AllureTestNg

      public AllureTestNg(io.qameta.allure.AllureLifecycle lifecycle, AllureTestNgTestFilter testFilter)
    • AllureTestNg

      public AllureTestNg(io.qameta.allure.AllureLifecycle lifecycle)
    • AllureTestNg

      public AllureTestNg()
  • Method Details

    • getLifecycle

      public io.qameta.allure.AllureLifecycle getLifecycle()
    • intercept

      public List<org.testng.IMethodInstance> intercept(List<org.testng.IMethodInstance> methods, org.testng.ITestContext context)
      Specified by:
      intercept in interface org.testng.IMethodInterceptor
    • onStart

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

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

      protected void createFakeResult(org.testng.ITestContext context, org.testng.ITestNGMethod method)
    • onFinish

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

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

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

      protected boolean shouldSkipReportingFor(org.testng.ITestResult testResult)
    • startTest

      protected void startTest(org.testng.ITestResult testResult, String parentUuid, String uuid)
    • startTest

      protected void startTest(org.testng.ITestContext context, org.testng.ITestNGMethod method, org.testng.IClass iClass, Object[] params, String parentUuid, String uuid)
    • onTestSuccess

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

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

      protected void stopTest(String uuid, Throwable throwable, io.qameta.allure.model.Status status)
    • onTestSkipped

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

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

      public void beforeInvocation(org.testng.IInvokedMethod method, org.testng.ITestResult testResult)
      Specified by:
      beforeInvocation in interface org.testng.IInvokedMethodListener
    • afterInvocation

      public void afterInvocation(org.testng.IInvokedMethod method, org.testng.ITestResult testResult)
      Specified by:
      afterInvocation in interface org.testng.IInvokedMethodListener
    • onConfigurationSuccess

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

      public void onConfigurationFailure(org.testng.ITestResult itr)
      Reports a failed configuration method as a run-level error rather than as a test result.

      The configuration method is not a test case: a test result standing in for it is counted in the run statistics and, having a history id no execution ever produces, survives every retry. The tests the failure prevented are reported by TestNG itself through onTestSkipped(ITestResult), with their real parameters, so they keep their own identity and a later green run replaces them.

      Specified by:
      onConfigurationFailure in interface org.testng.IConfigurationListener
    • onConfigurationSkip

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

      public void beforeDataProviderExecution(org.testng.IDataProviderMethod dataProviderMethod, org.testng.ITestNGMethod method, org.testng.ITestContext iTestContext)
      Specified by:
      beforeDataProviderExecution in interface org.testng.IDataProviderListener
    • afterDataProviderExecution

      public void afterDataProviderExecution(org.testng.IDataProviderMethod dataProviderMethod, org.testng.ITestNGMethod method, org.testng.ITestContext iTestContext)
      Specified by:
      afterDataProviderExecution in interface org.testng.IDataProviderListener
    • onDataProviderFailure

      public void onDataProviderFailure(org.testng.ITestNGMethod method, org.testng.ITestContext ctx, RuntimeException t)
      Specified by:
      onDataProviderFailure in interface org.testng.IDataProviderListener
    • getStatus

      protected io.qameta.allure.model.Status getStatus(Throwable throwable)