public class ExtentReports extends AbstractProcessor implements Writable, AnalysisTypeConfigurable
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 |
addTestRunnerOutput(List<String> log)
Adds logs from test framework tools to the test-runner logs view (if
available in the reporter)
|
void |
addTestRunnerOutput(String log)
Adds logs from test framework tools to the test-runner logs view (if
available in the reporter)
|
void |
attachReporter(ExtentObserver... observer)
Attach a
ExtentObserver reporter, allowing it to access all
started tests, nodes and logs |
protected void |
attachReporter(List<ExtentObserver> observerList) |
void |
createDomainFromJsonArchive(File jsonFile)
Creates the internal models by consuming a JSON archive from a previous
run session.
|
void |
createDomainFromJsonArchive(String jsonFilePath)
Creates the internal models by consuming a JSON archive from a previous
run session.
|
ExtentTest |
createTest(Class<? extends IGherkinFormatterModel> type,
String name)
Creates a BDD-style test representing one of the
IGherkinFormatterModel classes such as:
Feature
Background
Scenario
Given
When
Then
And
But
|
ExtentTest |
createTest(Class<? extends IGherkinFormatterModel> type,
String name,
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,
String testName)
|
ExtentTest |
createTest(GherkinKeyword gherkinKeyword,
String name,
String description)
|
ExtentTest |
createTest(String name)
Creates a test
|
ExtentTest |
createTest(String name,
String description)
Creates a test with description
|
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
|
ReportStats |
getStats()
Returns an instance of
ReportStats with counts of tests executed
by their status (pass, fail, skip etc) |
protected void |
onAuthorAssigned(Author x,
Test test) |
protected void |
onCategoryAssigned(Category x,
Test test) |
protected void |
onDeviceAssigned(Device x,
Test test) |
void |
removeTest(ExtentTest test)
Removes a test
|
void |
removeTest(String name)
Removes a test by name
|
void |
setAnalysisStrategy(AnalysisStrategy strategy)
Type of AnalysisStrategy for the reporter.
|
void |
setGherkinDialect(String language)
Allows setting the target language for Gherkin keywords.
|
void |
setReportUsesManualConfiguration(boolean useManualConfig)
Use this setting when building post-execution reports, such as from
TestNG IReporter.
|
void |
setSystemInfo(String k,
String v)
Adds any applicable system information to all started reporters
|
ExtentReports |
tryResolveMediaPath(String[] path)
Tries to resolve a
Media location if the supplied path is not
found using supplied locations. |
convertRawEntities, onAuthorAdded, onCategoryAdded, onDeviceAdded, onFlush, onLogCreated, onMediaAdded, onMediaAdded, onNodeCreated, onReportLogAdded, onSystemInfoAdded, onTestCreated, onTestRemovedpublic void attachReporter(ExtentObserver... observer)
ExtentObserver reporter, allowing it to access all
started tests, nodes and logsobserver - ExtentObserver reporterpublic ExtentTest createTest(Class<? extends IGherkinFormatterModel> type, String name, 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 typename - Name of testdescription - A short description of the testExtentTest objectpublic ExtentTest createTest(Class<? extends IGherkinFormatterModel> type, String name)
IGherkinFormatterModel classes such as:
Example:
extent.createTest(Feature.class, "feature"); extent.createTest(Scenario.class, "scenario"); extent.createTest(Given.class, "given");
type - A IGherkinFormatterModel typename - Name of testExtentTest objectpublic ExtentTest createTest(GherkinKeyword gherkinKeyword, String name, 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 GherkinKeywordname - Name of testdescription - A short description of the testExtentTest objectpublic ExtentTest createTest(GherkinKeyword gherkinKeyword, 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(String name, String description)
name - Name of testdescription - A short test descriptionExtentTest objectpublic ExtentTest createTest(String name)
name - Name of testExtentTest objectpublic void removeTest(ExtentTest test)
test - ExtentTest objectpublic void removeTest(String name)
name - The test namepublic void flush()
public void setSystemInfo(String k, String v)
Example:
extent.setSystemInfo("HostName", "AventStack");
k - Name of system variablev - Value of system variablepublic void addTestRunnerOutput(List<String> log)
TestNG usage example:
extent.setTestRunnerOutput(Reporter.getOutput());
log - Log string from the test runner frameworks such as TestNG or
JUnitpublic void addTestRunnerOutput(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(String[] path)
Media 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.path - Dirs used to create absolute path of the Media objectExtentReportspublic void createDomainFromJsonArchive(File jsonFile) throws IOException
appendExisting, with the exception of being
accessible by all reporters instead of just one.jsonFile - The JSON archive fileIOException - Exception thrown if the jsonFile is not foundpublic void createDomainFromJsonArchive(String jsonFilePath) throws IOException
appendExisting, with the exception of being
accessible by all reporters instead of just one.jsonFilePath - The JSON archive fileIOException - 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 void setAnalysisStrategy(AnalysisStrategy strategy)
There are 2 types of strategies available:
setAnalysisStrategy in interface AnalysisTypeConfigurablestrategy - AnalysisStrategy determines the type of analysis
(dashboard) created for the reporter. Not all reporters will
support this setting.public void setGherkinDialect(String language) throws UnsupportedEncodingException
Default setting is "en"
language - A valid dialect from gherkin-languages.jsonUnsupportedEncodingException - Thrown if the language is one of the supported language from
gherkin-languages.jsonpublic ReportStats getStats()
ReportStats with counts of tests executed
by their status (pass, fail, skip etc)ReportStatsprotected final void attachReporter(List<ExtentObserver> observerList)
Copyright © 2020. All rights reserved.