Class FileSystemResultsWriter

java.lang.Object
io.qameta.allure.FileSystemResultsWriter
All Implemented Interfaces:
AllureResultsWriter

public class FileSystemResultsWriter extends Object implements AllureResultsWriter
Writes Allure result model objects and attachments to the file system.

Create a writer with an output directory and pass it to an AllureLifecycle when results should be persisted as standard Allure files. The writer creates directories as needed and names files consistently with the Allure format.

  • Constructor Details

    • FileSystemResultsWriter

      public FileSystemResultsWriter(Path outputDirectory)
      Creates a file system results writer with the supplied values.
      Parameters:
      outputDirectory - the output directory
    • FileSystemResultsWriter

      public FileSystemResultsWriter(Path outputDirectory, boolean cleanBeforeRun, boolean cleanOnlyOnce)
      Creates a file system results writer with the supplied values.
      Parameters:
      outputDirectory - the output directory
      cleanBeforeRun - the clean before run
      cleanOnlyOnce - the clean only once
  • Method Details

    • write

      public void write(io.qameta.allure.model.TestResult testResult)
      Writes Allure test result bean.
      Specified by:
      write in interface AllureResultsWriter
      Parameters:
      testResult - the given bean to write.
    • write

      public void write(io.qameta.allure.model.TestResultContainer testResultContainer)
      Writes Allure test result container bean.
      Specified by:
      write in interface AllureResultsWriter
      Parameters:
      testResultContainer - the given bean to write.
    • write

      public void write(String source, InputStream attachment)
      Writes given attachment. Will close the given stream.
      Specified by:
      write in interface AllureResultsWriter
      Parameters:
      source - the file name of the attachment. Make sure that file name matches the following glob:
      *-attachment*
      . The right way to generate attachment is generate UUID, determinate attachment extension and then use it as
      {UUID}-attachment.{ext}
      attachment - the steam that contains attachment body.
    • generateTestResultName

      protected static String generateTestResultName()
      Generates and returns the test result name.
      Returns:
      the generated test result name
    • generateTestResultName

      protected static String generateTestResultName(String uuid)
      Generates and returns the test result name.
      Parameters:
      uuid - the Allure UUID of the model object
      Returns:
      the generated test result name
    • generateTestResultContainerName

      protected static String generateTestResultContainerName()
      Generates and returns the test result container name.
      Returns:
      the generated test result container name
    • generateTestResultContainerName

      protected static String generateTestResultContainerName(String uuid)
      Generates and returns the test result container name.
      Parameters:
      uuid - the Allure UUID of the model object
      Returns:
      the generated test result container name