Package dev.aherscu.qa.jgiven.reporter
Class AbstractQaJgivenReporter<M,T extends AbstractQaJgivenReporter<?,?>>
- java.lang.Object
-
- dev.aherscu.qa.jgiven.reporter.AbstractQaJgivenReporter<M,T>
-
- Type Parameters:
M
- one of JGiven's report models:CompleteReportModel
, *ScenarioModel
, orReportModelFile
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 itsgenerateReport(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 callgenerate()
-- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractQaJgivenReporter.AbstractQaJgivenReporterBuilder<M,T extends AbstractQaJgivenReporter<?,?>,C extends AbstractQaJgivenReporter<M,T>,B extends AbstractQaJgivenReporter.AbstractQaJgivenReporterBuilder<M,T,C,B>>
-
Field Summary
Fields Modifier and Type Field Description protected String
datePattern
protected boolean
debug
static String
DEFAULT_DATE_PATTERN
static String
DEFAULT_REFERENCE_TAG
static String
DEFAULT_SCREENSHOT_SCALE
protected File
outputDirectory
protected boolean
pdf
protected String
referenceTag
protected String
screenshotScale
protected File
sourceDirectory
protected String
templateResource
-
Constructor Summary
Constructors Modifier Constructor Description AbstractQaJgivenReporter()
protected
AbstractQaJgivenReporter(AbstractQaJgivenReporter.AbstractQaJgivenReporterBuilder<M,T,?,?> b)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected com.samskivert.mustache.Mustache.Compiler
compiler()
Hook for customizing the Mustache compiler.abstract void
generate()
Hook for implementing different reporting strategies.void
generateReport(List<org.testng.xml.XmlSuite> xmlSuites, List<org.testng.ISuite> suites, String outputDirectory)
protected Collection<File>
listJGivenReports()
AbstractQaJgivenReporter<M,T>
prepare()
Prepares the output directory.protected File
reportFile(File reportModelFile, String extension)
protected QaJGivenReportModel<M>
reportModel(File targetReportFile)
Hook for initiating aQaJGivenReportModel
; by default, initializes with a specified JGiven JSON report file.protected com.samskivert.mustache.Template
template()
Hook for loading a Mustache template; by default, loads fromtemplateResource
specified during construction.protected String
templateResourceParamFrom(org.testng.xml.XmlSuite xmlSuite, String defaultTemplateResource)
abstract AbstractQaJgivenReporter.AbstractQaJgivenReporterBuilder<M,T,?,?>
toBuilder()
String
toString()
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, orDEFAULT_REFERENCE_TAG
screenshotScale the screenshot scale to apply when embedding files into reports, orDEFAULT_SCREENSHOT_SCALE
datePattern the date pattern to use for presenting dates, orDEFAULT_DATE_PATTERN
templateResourceXXX the template resource file name to apply; theXXX
is the concrete reporter implementation name (class)
-
-
-
Field Detail
-
DEFAULT_DATE_PATTERN
public static final String DEFAULT_DATE_PATTERN
- See Also:
- Constant Field Values
-
DEFAULT_REFERENCE_TAG
public static final String DEFAULT_REFERENCE_TAG
- See Also:
- Constant Field Values
-
DEFAULT_SCREENSHOT_SCALE
public static final String DEFAULT_SCREENSHOT_SCALE
- See Also:
- Constant Field Values
-
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
-
-
Constructor Detail
-
AbstractQaJgivenReporter
protected AbstractQaJgivenReporter(AbstractQaJgivenReporter.AbstractQaJgivenReporterBuilder<M,T,?,?> b)
-
AbstractQaJgivenReporter
public AbstractQaJgivenReporter()
-
-
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 interfaceorg.testng.IReporter
- Parameters:
xmlSuites
- The list ofXmlSuite
suites
- The list ofISuite
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
-
toBuilder
public abstract AbstractQaJgivenReporter.AbstractQaJgivenReporterBuilder<M,T,?,?> toBuilder()
-
compiler
protected com.samskivert.mustache.Mustache.Compiler compiler()
Hook for customizing the Mustache compiler.- Returns:
- default Mustache compiler
-
listJGivenReports
protected final Collection<File> listJGivenReports()
-
reportModel
protected QaJGivenReportModel<M> reportModel(File targetReportFile)
Hook for initiating aQaJGivenReportModel
; 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 fromtemplateResource
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
-
-