public class ExtentReports extends 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
|
ExtentTest |
createTest(Class<? extends IGherkinFormatterModel> type,
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(Class<? extends IGherkinFormatterModel> type,
String testName,
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 testName,
String description)
|
ExtentTest |
createTest(String testName)
Creates a test
|
ExtentTest |
createTest(String testName,
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
|
protected boolean |
getAllowManualConfig()
Returns the current value of using manual configuration for test time-stamps
|
protected TestAttributeTestContextProvider<Author> |
getAuthorContextInfo()
Returns the context of author with the list of tests for each
|
protected List<ExtentReporter> |
getReporterCollection()
Retrieve a list of all started reporters
|
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(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
|
protected void |
setSystemInfo(SystemAttribute sa)
Add a system attribute
|
protected void |
setTestRunnerLogs(String log)
Add a test runner log
|
void |
setTestRunnerOutput(List<String> log)
Adds logs from test framework tools to the test-runner logs view (if available in the reporter)
|
void |
setTestRunnerOutput(String log)
Adds logs from test framework tools to the test-runner logs view (if available in the reporter)
|
public void attachReporter(ExtentReporter... reporter)
ExtentReporter
reporter, allowing it to access all started tests, nodes and logs
Available reporter types are:
reporter
- ExtentReporter
reporterpublic List<ExtentReporter> getStartedReporters()
ExtentReporter
public ExtentTest createTest(Class<? extends IGherkinFormatterModel> type, String testName, 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(Class<? extends IGherkinFormatterModel> type, 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, String testName, 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 GherkinKeyword
testName
- 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 GherkinKeyword
testName
- Name of testExtentTest
objectpublic ExtentTest createTest(String testName, String description)
testName
- Name of testdescription
- A short test descriptionExtentTest
objectpublic ExtentTest createTest(String testName)
testName
- Name of testExtentTest
objectpublic void removeTest(ExtentTest test)
test
- ExtentTest
objectpublic void flush()
public void setSystemInfo(String k, String v)
Example:
extent.setSystemInfo("HostName", "AventStack-PC");
k
- Name of system variablev
- Value of system variablepublic void setTestRunnerOutput(List<String> log)
TestNG usage example:
extent.setTestRunnerOutput(Reporter.getOutput());
log
- Log string from the test runner frameworks such as TestNG or JUnitpublic void setTestRunnerOutput(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 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:
strategy
- AnalysisStrategy
determines the type of analysis (dashboard)
created for the reporter. Not all reporters will support this setting.public ReportConfigurator config()
ReportConfigurator
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 ReportStatusStats getStats()
ReportStatusStats
with counts of tests executed
by their status (pass, fail, skip etc)ReportStatusStats
protected 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 List<ExtentReporter> getReporterCollection()
ExtentReporter
objectsprotected void saveTest(Test test)
test
- a Test
objectprotected void removeTest(Test test)
test
- a Test
objectprotected TestAttributeTestContextProvider<Author> getAuthorContextInfo()
TestAttributeTestContextProvider
objectprotected void end()
protected void setSystemInfo(SystemAttribute sa)
sa
- a SystemAttribute
objectprotected void setTestRunnerLogs(String log)
log
- a log eventprotected void setAllowManualConfig(boolean useManualConfig)
useManualConfig
- setting for manual configurationprotected boolean getAllowManualConfig()
Copyright © 2018. All rights reserved.