Class AllureManager

java.lang.Object
com.shaft.tools.io.internal.AllureManager

public class AllureManager extends Object
Internal utility class that manages the Allure reporting lifecycle for SHAFT test runs. Responsibilities include initialising the results directory, generating an allurerc.yaml configuration file, bootstrapping the Allure 3 CLI (downloaded automatically when not present), invoking it to produce the single-file HTML report, and optionally producing a ZIP archive.

This class is not intended for direct use in test code. It is invoked automatically by the SHAFT framework listeners at suite start and finish.

Allure 3 CLI resolution order (batteries-included):

  1. A globally installed allure binary already on PATH.
  2. npx on PATHnpx --yes allure@<version> (auto-downloads).
  3. Portable Node.js downloaded to ~/.m2/repository/nodejs/ → its bundled npx → same npx --yes allure@<version> invocation.
No manual installation is required; SHAFT handles it transparently.

Thread safety: all public methods are static and intended to be called from a single thread (the test runner thread). The result directory fields are mutable class-level state and should not be accessed concurrently.

  • Method Details

    • initializeAllureReportingEnvironment

      public static void initializeAllureReportingEnvironment()
      Initialises the Allure reporting environment before a test suite begins. This method:
      1. Resolves the Allure results folder path from SHAFT properties.
      2. Optionally cleans the report and results directories.
      3. Writes convenience shell/batch scripts to the project root for manual report generation.
      4. Writes the current JVM system properties to environment.xml in the results directory.

      The Allure 3 CLI is resolved (and downloaded if necessary) automatically at report-generation time; no separate installation step is required.

      Example (called automatically by SHAFT listeners):

      AllureManager.initializeAllureReportingEnvironment();
      
    • openAllureReportAfterExecution

      public static void openAllureReportAfterExecution()
      Generates the Allure HTML report and opens it in the default browser when SHAFT.Properties.allure.automaticallyOpen() is true. The generated report is copied to the allure-report directory, renamed (optionally with a timestamp when accumulateReports is enabled), and the intermediate output directory is deleted.

      Example (called automatically by SHAFT listeners after suite completion):

      AllureManager.openAllureReportAfterExecution();
      
    • generateAllureReportArchive

      public static void generateAllureReportArchive()
      Generates a self-contained ZIP archive of the Allure report when SHAFT.Properties.allure.generateArchive() is true. The archive is written to the project directory with a timestamped filename (e.g. generatedReport_2024-01-15_10-30-00-000.zip).

      This method is a no-op when archive generation is disabled in properties.

      Example (called automatically by SHAFT listeners):

      AllureManager.generateAllureReportArchive();