Class AbstractQaJgivenReporter<M,​T extends AbstractQaJgivenReporter<?,​?>>

  • Type Parameters:
    M - one of JGiven's report models: CompleteReportModel, * ScenarioModel, or ReportModelFile
    T - specific type of reporter
    All Implemented Interfaces:
    org.testng.IReporter, org.testng.ITestNGListener
    Direct Known Subclasses:
    QaJGivenPerClassReporter, QaJGivenPerMethodReporter, QaJGivenReporter

    public abstract class AbstractQaJgivenReporter<M,​T extends AbstractQaJgivenReporter<?,​?>>
    extends Object
    implements org.testng.IReporter
    Base functionality and defaults for all kinds of reporters.

    Can be invoked as a TestNG Reporter, hence supports IReporter by implementing its generateReport(List, List, String) and provides a no-args constructor. It also can be invoked from other workflow engine, such as from a Maven plugin, which should just call generate() -- see the qa-testrail-reporter and qa-jgiven-reporter-maven-plugin sibling modules.

    Implementors are required to specify the generate() method.

    See Also:
    TestNG Reporter configuration
    • Field Detail

      • sourceDirectory

        protected final File sourceDirectory
      • outputDirectory

        protected final File outputDirectory
      • debug

        protected final boolean debug
      • screenshotScale

        protected final String screenshotScale
      • datePattern

        protected final String datePattern
      • pdf

        protected final boolean pdf
      • referenceTag

        protected final String referenceTag
      • templateResource

        protected final String templateResource
    • Method Detail

      • generate

        public abstract void generate()
        Hook for implementing different reporting strategies.
      • generateReport

        public void generateReport​(List<org.testng.xml.XmlSuite> xmlSuites,
                                   List<org.testng.ISuite> suites,
                                   String outputDirectory)
        Specified by:
        generateReport in interface org.testng.IReporter
        Parameters:
        xmlSuites - The list of XmlSuite
        suites - The list of ISuite
        outputDirectory - The output directory is ignored, since it is specified by JGiven reporter infrastructure
      • prepare

        public AbstractQaJgivenReporter<M,​T> prepare()
        Prepares the output directory. By default, just makes it if it does not exist. Multiple executions, without cleaning in-between, may cause corrupted reports.
        Returns:
        this reporter
      • compiler

        protected com.samskivert.mustache.Mustache.Compiler compiler()
        Hook for customizing the Mustache compiler.
        Returns:
        default Mustache compiler
      • listJGivenReports

        protected final Collection<File> listJGivenReports()
      • reportFile

        protected final File reportFile​(File reportModelFile,
                                        String extension)
      • reportModel

        protected QaJGivenReportModel<M> reportModel​(File targetReportFile)
        Hook for initiating a QaJGivenReportModel; by default, initializes with a specified JGiven JSON report file.
        Parameters:
        targetReportFile - JGiven JSON report file
        Returns:
        the report model
      • template

        protected com.samskivert.mustache.Template template()
        Hook for loading a Mustache template; by default, loads from templateResource specified during construction.
        Returns:
        the template
      • templateResourceParamFrom

        protected final String templateResourceParamFrom​(org.testng.xml.XmlSuite xmlSuite,
                                                         String defaultTemplateResource)
      • with

        protected AbstractQaJgivenReporter<M,​T> with​(org.testng.xml.XmlSuite xmlSuite)
        Builds a new reporter configured per following TestNG XML suite parameters:
        referenceTag
        the reference tag identifier, or DEFAULT_REFERENCE_TAG
        screenshotScale
        the screenshot scale to apply when embedding files into reports, or DEFAULT_SCREENSHOT_SCALE
        datePattern
        the date pattern to use for presenting dates, or DEFAULT_DATE_PATTERN
        templateResourceXXX
        the template resource file name to apply; the XXX is the concrete reporter implementation name (class)
        Parameters:
        xmlSuite - TestNG XML suite
        Returns:
        reporter configured