public class ExtentReports
extends java.lang.Object
The ExtentReports report client for starting reporters and building reports. For most applications, you should have one ExtentReports instance for the entire JVM.
ExtentReports itself does not build any reports, but allows reporters to access information, which in turn build the said reports. An example of building an HTML report and adding information to ExtentX:
ExtentHtmlReporter html = new ExtentHtmlReporter("Extent.html");
ExtentXReporter extentx = new ExtentXReporter("localhost");
ExtentReports extent = new ExtentReports();
extent.attachReporter(html, extentx);
extent.createTest("TestName").pass("Test Passed");
extent.flush();
A few notes:
flush method to ensure
information is written to the started reporters.createTest methodExtentTest,
GherkinKeyword,
IGherkinFormatterModel,
Status| Constructor and Description |
|---|
ExtentReports() |
| Modifier and Type | Method and Description |
|---|---|
void |
attachReporter(ExtentReporter... reporter)
Attach a
ExtentReporter reporter, allowing it to access all started
tests, nodes and logs |
ReportConfigurator |
config()
Provides common report configurations
|
void |
createDomainFromJsonArchive(java.io.File jsonFile)
Creates the internal models by consuming a JSON archive from a previous run
session.
|
void |
createDomainFromJsonArchive(java.lang.String jsonFilePath)
Creates the internal models by consuming a JSON archive from a previous run
session.
|
ExtentTest |
createTest(java.lang.Class<? extends IGherkinFormatterModel> type,
java.lang.String testName)
Creates a BDD-style test representing one of the
IGherkinFormatterModel classes such as:
Feature
Background
Scenario
Given
When
Then
And
But
|
ExtentTest |
createTest(java.lang.Class<? extends IGherkinFormatterModel> type,
java.lang.String testName,
java.lang.String description)
Creates a BDD-style test with description representing one of the
IGherkinFormatterModel classes such as:
Feature
Background
Scenario
Given
When
Then
And
But
|
ExtentTest |
createTest(GherkinKeyword gherkinKeyword,
java.lang.String testName)
|
ExtentTest |
createTest(GherkinKeyword gherkinKeyword,
java.lang.String testName,
java.lang.String description)
|
ExtentTest |
createTest(java.lang.String testName)
Creates a test
|
ExtentTest |
createTest(java.lang.String testName,
java.lang.String description)
Creates a test with description
|
protected void |
deregister(ExtentReporter reporter)
Unsubscribe the reporter.
|
protected void |
end()
Ends logging, stops and clears the list of reporters
|
void |
flush()
Writes test information from the started reporters to their output view
extent-html-formatter: flush output to HTML file
extent-klov-reporter: updates MongoDB collections
extent-email-formatter (pro-only): creates or appends to an HTML
file
ConsoleLogger: no action taken
|
void |
generateRecentStatus()
|
protected boolean |
getAllowManualConfig()
Returns the current value of using manual configuration for test time-stamps
|
protected TestAttributeTestContextStore<Author> |
getAuthorContextInfo()
Returns the context of author with the list of tests for each
|
protected java.util.List<ExtentReporter> |
getReporterCollection()
Retrieve a list of all started reporters
|
java.lang.Boolean |
getReportUsesManualConfiguration() |
java.util.List<ExtentReporter> |
getStartedReporters()
Returns a list of started reporters
|
ReportStatusStats |
getStats()
Returns an instance of
ReportStatusStats with counts of tests
executed by their status (pass, fail, skip etc) |
protected void |
register(ExtentReporter reporter)
Subscribe the reporter to receive updates when making calls to the API
|
void |
removeTest(ExtentTest test)
Removes a test
|
protected void |
removeTest(Test test)
Removes the test and notifies all started reporters
|
protected void |
saveTest(Test test)
Saves the started test and notifies all started reporters
|
protected void |
setAllowManualConfig(boolean useManualConfig)
Setting to allow user driven configuration for test time-stamps
|
void |
setAnalysisStrategy(AnalysisStrategy strategy)
Type of AnalysisStrategy for the reporter.
|
void |
setGherkinDialect(java.lang.String language)
Allows setting the target language for Gherkin keywords.
|
protected void |
setMediaPathResolveDir(java.lang.String[] imagePathResolveDir) |
void |
setReportUsesManualConfiguration(boolean useManualConfig)
Use this setting when building post-execution reports, such as from TestNG
IReporter.
|
void |
setSystemInfo(java.lang.String k,
java.lang.String v)
Adds any applicable system information to all started reporters
|
protected void |
setSystemInfo(SystemAttribute sa)
Add a system attribute
|
protected void |
setTestRunnerLogs(java.lang.String log)
Add a test runner log
|
void |
setTestRunnerOutput(java.util.List<java.lang.String> log)
Adds logs from test framework tools to the test-runner logs view (if
available in the reporter)
|
void |
setTestRunnerOutput(java.lang.String log)
Adds logs from test framework tools to the test-runner logs view (if
available in the reporter)
|
ExtentReports |
tryResolveMediaPath()
Tries to resolve a
ScreenCapture location if the supplied path is not found using
default locations. |
ExtentReports |
tryResolveMediaPath(java.lang.String[] paths)
Tries to resolve a
ScreenCapture location if the supplied path is not found using
supplied locations. |
public void attachReporter(ExtentReporter... reporter)
ExtentReporter reporter, allowing it to access all started
tests, nodes and logs
Available reporter types are:
reporter - ExtentReporter reporterpublic java.util.List<ExtentReporter> getStartedReporters()
ExtentReporterpublic ExtentTest createTest(java.lang.Class<? extends IGherkinFormatterModel> type, java.lang.String testName, java.lang.String description)
IGherkinFormatterModel classes such as:
Example:
extent.createTest(Feature.class, "feature", "description"); extent.createTest(Scenario.class, "scenario", "description"); extent.createTest(Given.class, "given", "description");
type - A IGherkinFormatterModel typetestName - Name of testdescription - A short description of the testExtentTest objectpublic ExtentTest createTest(java.lang.Class<? extends IGherkinFormatterModel> type, java.lang.String testName)
IGherkinFormatterModel classes such as:
Example:
extent.createTest(Feature.class, "feature"); extent.createTest(Scenario.class, "scenario"); extent.createTest(Given.class, "given");
type - A IGherkinFormatterModel typetestName - Name of testExtentTest objectpublic ExtentTest createTest(GherkinKeyword gherkinKeyword, java.lang.String testName, java.lang.String description)
Example:
extent.createTest(new GherkinKeyword("Feature"), "feature", "description");
extent.createTest(new GherkinKeyword("Scenario"), "scenario", "description");
extent.createTest(new GherkinKeyword("Given"), "given", "description");
gherkinKeyword - Name of the GherkinKeywordtestName - Name of testdescription - A short description of the testExtentTest objectpublic ExtentTest createTest(GherkinKeyword gherkinKeyword, java.lang.String testName)
Example:
extent.createTest(new GherkinKeyword("Feature"), "feature");
extent.createTest(new GherkinKeyword("Scenario"), "scenario");
extent.createTest(new GherkinKeyword("Given"), "given");
gherkinKeyword - Name of the GherkinKeywordtestName - Name of testExtentTest objectpublic ExtentTest createTest(java.lang.String testName, java.lang.String description)
testName - Name of testdescription - A short test descriptionExtentTest objectpublic ExtentTest createTest(java.lang.String testName)
testName - Name of testExtentTest objectpublic void removeTest(ExtentTest test)
test - ExtentTest objectpublic void flush()
public void setSystemInfo(java.lang.String k,
java.lang.String v)
Example:
extent.setSystemInfo("HostName", "AventStack-PC");
k - Name of system variablev - Value of system variablepublic void setTestRunnerOutput(java.util.List<java.lang.String> log)
TestNG usage example:
extent.setTestRunnerOutput(Reporter.getOutput());
log - Log string from the test runner frameworks such as TestNG or JUnitpublic void setTestRunnerOutput(java.lang.String log)
TestNG usage example:
for (String s : Reporter.getOutput()) {
extent.setTestRunnerOutput(s);
}
log - Log string from the test runner frameworks such as TestNG or JUnitpublic ExtentReports tryResolveMediaPath()
ScreenCapture location if the supplied path is not found using
default locations. This can resolve cases where the default path was supplied to be relative
for a FileReporter. If the absolute path is not determined, the supplied will be used.
below paths are used to locate the image:
ExtentKlovReporterpublic ExtentReports tryResolveMediaPath(java.lang.String[] paths)
ScreenCapture location if the supplied path is not found using
supplied locations. This can resolve cases where the default path was supplied to be relative
for a FileReporter. If the absolute path is not determined, the supplied will be used.paths - Dirs used to create absolute path of the Media objectExtentKlovReporterpublic void createDomainFromJsonArchive(java.io.File jsonFile)
throws java.io.IOException
appendExisting, with the exception of being accessible by
all reporters instead of just one.jsonFile - The JSON archive filejava.io.IOException - Exception thrown if the jsonFile is not foundpublic void createDomainFromJsonArchive(java.lang.String jsonFilePath)
throws java.io.IOException
appendExisting, with the exception of being accessible by
all reporters instead of just one.jsonFilePath - The JSON archive filejava.io.IOException - Exception thrown if the jsonFilePath is not foundpublic void setReportUsesManualConfiguration(boolean useManualConfig)
If this setting is enabled and time-stamps are not specified explicitly, the time-stamps of test creation are used.
useManualConfig - Set to true if building reports at the end of
execution with manual configurationpublic java.lang.Boolean getReportUsesManualConfiguration()
public void setAnalysisStrategy(AnalysisStrategy strategy)
There are 2 types of strategies available:
strategy - AnalysisStrategy determines the type of analysis
(dashboard) created for the reporter. Not all reporters will
support this setting.public ReportConfigurator config()
ReportConfiguratorpublic void setGherkinDialect(java.lang.String language)
throws java.io.UnsupportedEncodingException
Default setting is "en"
language - A valid dialect from gherkin-languages.jsonjava.io.UnsupportedEncodingException - Thrown if the language is one of the
supported language from gherkin-languages.jsonpublic ReportStatusStats getStats()
ReportStatusStats with counts of tests
executed by their status (pass, fail, skip etc)ReportStatusStatsprotected void register(ExtentReporter reporter)
reporter - ExtentReporter reporterprotected void deregister(ExtentReporter reporter)
stop
method and also remove the reporter from the list of started reportersreporter - ExtentReporter reporter to unsubscribeprotected java.util.List<ExtentReporter> getReporterCollection()
ExtentReporter objectsprotected void saveTest(Test test)
test - a Test objectprotected void removeTest(Test test)
test - a Test objectprotected TestAttributeTestContextStore<Author> getAuthorContextInfo()
TestAttributeTestContextStore objectpublic void generateRecentStatus()
Category,
Author, Exception, Nodes. This also ends and updates all internal
test information and refreshes ReportStatusStats and the distinct
list of StatusgenerateRecentStatus in interface ReportServiceprotected void end()
protected void setSystemInfo(SystemAttribute sa)
sa - a SystemAttribute objectprotected void setTestRunnerLogs(java.lang.String log)
log - a log eventprotected void setMediaPathResolveDir(java.lang.String[] imagePathResolveDir)
protected void setAllowManualConfig(boolean useManualConfig)
useManualConfig - setting for manual configurationprotected boolean getAllowManualConfig()
Copyright © 2020. All Rights Reserved.