Class AllureListener

java.lang.Object
com.shaft.listeners.AllureListener
All Implemented Interfaces:
io.qameta.allure.listener.ContainerLifecycleListener, io.qameta.allure.listener.FixtureLifecycleListener, io.qameta.allure.listener.LifecycleListener, io.qameta.allure.listener.StepLifecycleListener, io.qameta.allure.listener.TestLifecycleListener

public class AllureListener extends Object implements io.qameta.allure.listener.StepLifecycleListener, io.qameta.allure.listener.FixtureLifecycleListener, io.qameta.allure.listener.TestLifecycleListener, io.qameta.allure.listener.ContainerLifecycleListener
Allure lifecycle listener that integrates SHAFT's TestNG support with the Allure reporting engine.

This listener is registered automatically and hooks into all four Allure lifecycle interfaces: StepLifecycleListener, FixtureLifecycleListener, TestLifecycleListener, and ContainerLifecycleListener. The SHAFT-specific behaviour is in:

  • afterStepStop(StepResult) — updates TestNG configuration method metadata after each step completes
  • beforeFixtureStop(FixtureResult) — attaches configuration-method artefacts to the Allure report before a fixture (setup/teardown) finishes
  • beforeTestStop(TestResult) — promotes a SKIPPED test result to BROKEN when the skip was caused by a configuration-method failure or kill-switch activation, and attaches the exception stacktrace so it is readable in the Allure HTML report

Example — automatic registration via SPI:

// Listed in META-INF/services/io.qameta.allure.listener.LifecycleListener
// No manual registration required.
com.shaft.listeners.AllureListener
  • Constructor Details

    • AllureListener

      public AllureListener()
  • Method Details

    • beforeStepStart

      public void beforeStepStart(io.qameta.allure.model.StepResult result)
      Specified by:
      beforeStepStart in interface io.qameta.allure.listener.StepLifecycleListener
    • afterStepStart

      public void afterStepStart(io.qameta.allure.model.StepResult result)
      Specified by:
      afterStepStart in interface io.qameta.allure.listener.StepLifecycleListener
    • beforeStepUpdate

      public void beforeStepUpdate(io.qameta.allure.model.StepResult result)
      Specified by:
      beforeStepUpdate in interface io.qameta.allure.listener.StepLifecycleListener
    • afterStepUpdate

      public void afterStepUpdate(io.qameta.allure.model.StepResult result)
      Specified by:
      afterStepUpdate in interface io.qameta.allure.listener.StepLifecycleListener
    • beforeStepStop

      public void beforeStepStop(io.qameta.allure.model.StepResult result)
      Specified by:
      beforeStepStop in interface io.qameta.allure.listener.StepLifecycleListener
    • afterStepStop

      public void afterStepStop(io.qameta.allure.model.StepResult result)
      Invoked after each Allure step stops. If a TestNG ITestResult is available for the current thread, delegates to TestNGListenerHelper.updateConfigurationMethods(ITestResult) to keep configuration-method metadata in sync with the Allure step model.
      Specified by:
      afterStepStop in interface io.qameta.allure.listener.StepLifecycleListener
      Parameters:
      result - the StepResult representing the step that has just stopped
    • beforeContainerStart

      public void beforeContainerStart(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      beforeContainerStart in interface io.qameta.allure.listener.ContainerLifecycleListener
    • afterContainerStart

      public void afterContainerStart(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      afterContainerStart in interface io.qameta.allure.listener.ContainerLifecycleListener
    • beforeContainerUpdate

      public void beforeContainerUpdate(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      beforeContainerUpdate in interface io.qameta.allure.listener.ContainerLifecycleListener
    • afterContainerUpdate

      public void afterContainerUpdate(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      afterContainerUpdate in interface io.qameta.allure.listener.ContainerLifecycleListener
    • beforeContainerStop

      public void beforeContainerStop(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      beforeContainerStop in interface io.qameta.allure.listener.ContainerLifecycleListener
    • afterContainerStop

      public void afterContainerStop(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      afterContainerStop in interface io.qameta.allure.listener.ContainerLifecycleListener
    • beforeContainerWrite

      public void beforeContainerWrite(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      beforeContainerWrite in interface io.qameta.allure.listener.ContainerLifecycleListener
    • afterContainerWrite

      public void afterContainerWrite(io.qameta.allure.model.TestResultContainer container)
      Specified by:
      afterContainerWrite in interface io.qameta.allure.listener.ContainerLifecycleListener
    • beforeFixtureStart

      public void beforeFixtureStart(io.qameta.allure.model.FixtureResult result)
      Specified by:
      beforeFixtureStart in interface io.qameta.allure.listener.FixtureLifecycleListener
    • afterFixtureStart

      public void afterFixtureStart(io.qameta.allure.model.FixtureResult result)
      Specified by:
      afterFixtureStart in interface io.qameta.allure.listener.FixtureLifecycleListener
    • beforeFixtureUpdate

      public void beforeFixtureUpdate(io.qameta.allure.model.FixtureResult result)
      Specified by:
      beforeFixtureUpdate in interface io.qameta.allure.listener.FixtureLifecycleListener
    • afterFixtureUpdate

      public void afterFixtureUpdate(io.qameta.allure.model.FixtureResult result)
      Specified by:
      afterFixtureUpdate in interface io.qameta.allure.listener.FixtureLifecycleListener
    • beforeFixtureStop

      public void beforeFixtureStop(io.qameta.allure.model.FixtureResult result)
      Invoked before each Allure fixture (TestNG @BeforeXxx/@AfterXxx method) stops. Calls TestNGListenerHelper.attachConfigurationMethods() to attach any pending configuration-method artefacts to the Allure report before the fixture result is finalised.
      Specified by:
      beforeFixtureStop in interface io.qameta.allure.listener.FixtureLifecycleListener
      Parameters:
      result - the FixtureResult representing the fixture that is about to stop
    • afterFixtureStop

      public void afterFixtureStop(io.qameta.allure.model.FixtureResult result)
      Specified by:
      afterFixtureStop in interface io.qameta.allure.listener.FixtureLifecycleListener
    • beforeTestSchedule

      public void beforeTestSchedule(io.qameta.allure.model.TestResult result)
      Specified by:
      beforeTestSchedule in interface io.qameta.allure.listener.TestLifecycleListener
    • afterTestSchedule

      public void afterTestSchedule(io.qameta.allure.model.TestResult result)
      Specified by:
      afterTestSchedule in interface io.qameta.allure.listener.TestLifecycleListener
    • beforeTestUpdate

      public void beforeTestUpdate(io.qameta.allure.model.TestResult result)
      Specified by:
      beforeTestUpdate in interface io.qameta.allure.listener.TestLifecycleListener
    • afterTestUpdate

      public void afterTestUpdate(io.qameta.allure.model.TestResult result)
      Specified by:
      afterTestUpdate in interface io.qameta.allure.listener.TestLifecycleListener
    • beforeTestStart

      public void beforeTestStart(io.qameta.allure.model.TestResult result)
      Specified by:
      beforeTestStart in interface io.qameta.allure.listener.TestLifecycleListener
    • afterTestStart

      public void afterTestStart(io.qameta.allure.model.TestResult result)
      Specified by:
      afterTestStart in interface io.qameta.allure.listener.TestLifecycleListener
    • beforeTestStop

      public void beforeTestStop(io.qameta.allure.model.TestResult result)
      Invoked before each Allure test case stops. When the result status is Status.SKIPPED and the skip was caused by a non-intentional reason (configuration method failure or kill-switch activation rather than a deliberate SkipException), this method:
      1. Promotes the status to Status.BROKEN so the test appears as failed in the report.
      2. Attaches the full exception stacktrace as a readable text/plain attachment.

      Intentional skips — those raised by SHAFT's linked-issue skipper or the test-suite timeout guard — are left as Status.SKIPPED.

      Specified by:
      beforeTestStop in interface io.qameta.allure.listener.TestLifecycleListener
      Parameters:
      result - the TestResult that is about to be finalised
    • afterTestStop

      public void afterTestStop(io.qameta.allure.model.TestResult result)
      Specified by:
      afterTestStop in interface io.qameta.allure.listener.TestLifecycleListener
    • beforeTestWrite

      public void beforeTestWrite(io.qameta.allure.model.TestResult result)
      Specified by:
      beforeTestWrite in interface io.qameta.allure.listener.TestLifecycleListener
    • afterTestWrite

      public void afterTestWrite(io.qameta.allure.model.TestResult result)
      Specified by:
      afterTestWrite in interface io.qameta.allure.listener.TestLifecycleListener