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| Modifier and Type | Field and Description |
|---|---|
protected AnalysisStrategy |
strategy |
protected boolean |
usesManualConfiguration |
| Constructor and Description |
|---|
ExtentReports() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
attach(ExtentReporter reporter) |
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(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
|
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
|
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 |
createTest(Test test) |
protected void |
detach(ExtentReporter reporter) |
protected void |
end() |
void |
flush()
Writes test information from the started reporters to their output view
ExtentHtmlReporter - creates or appends to an HTML file
ExtentXReporter - updates database
ExtentEmailReporter - creates or appends to an HTML file
ExtentLogger - no action taken
|
protected TestAttributeTestContextProvider<Author> |
getAuthorContextInfo() |
void |
removeTest(ExtentTest test)
Removes a test
|
protected void |
removeTest(Test test) |
void |
setAnalysisStrategy(AnalysisStrategy strategy)
Type of AnalysisStrategy for the reporter.
|
void |
setReportUsesManualConfiguration(boolean b)
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) |
protected void |
setTestRunnerLogs(java.lang.String 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)
|
protected boolean usesManualConfiguration
protected AnalysisStrategy strategy
public void attachReporter(ExtentReporter... reporter)
ExtentReporter reporter, allowing it to access all started tests, nodes and logs
Available reporter types are:
reporter - ExtentReporter reporterpublic 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, "bddTest", "description");
Note: BDD styling is not available on ExtentX server. Your tests will show as regular nodes 2 levels deep.
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, "bddTest");
Note: BDD styling is not available on ExtentX server. Your tests will show as regular nodes 2 levels deep.
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"), "bddTest", "description");
Note: BDD styling is not available on ExtentX server. Your tests will show as regular nodes 2 levels deep.
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"), "bddTest", "description");
Note: BDD styling is not available on ExtentX server. Your tests will show as regular nodes 2 levels deep.
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)
log - Log string from the test runner frameworks such as TestNG or JUnitpublic void setTestRunnerOutput(java.lang.String log)
log - Log string from the test runner frameworks such as TestNG or JUnitpublic void setReportUsesManualConfiguration(boolean b)
b - 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()
ReportConfiguratorprotected void attach(ExtentReporter reporter)
protected void detach(ExtentReporter reporter)
protected void createTest(Test test)
protected void removeTest(Test test)
protected TestAttributeTestContextProvider<Author> getAuthorContextInfo()
protected void end()
protected void setSystemInfo(SystemAttribute sa)
protected void setTestRunnerLogs(java.lang.String log)
Copyright © 2017. All Rights Reserved.