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
|
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
|
void |
detachReporter(ExtentReporter... reporter)
Detach a
ExtentReporter reporter from the collection of started reporters. |
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
|
TestDisplayOrder |
getTestDisplayOrder()
Gets the order in which tests are displayed in the report.
|
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
|
void |
setTestDisplayOrder(TestDisplayOrder order)
Sets the order in which tests are displayed in the report.
|
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)
|
public void attachReporter(ExtentReporter... reporter)
ExtentReporter
reporter, allowing it to access all started tests, nodes and logs
Available reporter types are:
reporter
- ExtentReporter
reporterpublic void detachReporter(ExtentReporter... reporter)
ExtentReporter
reporter from the collection of started reporters. Calling this
method will stop any additional tests added to the reporter.
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 GherkinKeyword
testName
- 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 GherkinKeyword
testName
- 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 flush()
public void setTestDisplayOrder(TestDisplayOrder order)
order
- TestDisplayOrder
public TestDisplayOrder getTestDisplayOrder()
TestDisplayOrder
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 ReportConfigurator config()
ReportConfigurator
object