public class ExtentReports extends LogSettings
Modifier and Type | Field and Description |
---|---|
protected File |
configFile |
protected SuiteTimeInfo |
suiteTimeInfo |
protected com.relevantcodes.extentreports.SystemInfo |
systemInfo |
protected List<ExtentTest> |
testList |
Constructor and Description |
---|
ExtentReports(String filePath)
Initializes Extent HTML report
Default setting (true) is used for replaceExisting
Default setting
DisplayOrder.OLDEST_FIRST is used for DisplayOrder
Default setting NetworkMode.ONLINE for NetworkMode is used
|
ExtentReports(String filePath,
Boolean replaceExisting)
Initializes Extent HTML report
Default setting
DisplayOrder.OLDEST_FIRST is used for DisplayOrder
Default setting NetworkMode.ONLINE for NetworkMode is used
|
ExtentReports(String filePath,
Boolean replaceExisting,
DisplayOrder displayOrder)
Initializes Extent HTML report
Default setting
NetworkMode.ONLINE for NetworkMode is used
|
ExtentReports(String filePath,
Boolean replaceExisting,
DisplayOrder displayOrder,
Locale locale)
Initializes a localized version of Extent HTML report.
|
ExtentReports(String filePath,
Boolean replaceExisting,
DisplayOrder displayOrder,
NetworkMode networkMode)
Initializes Extent HTML report
|
ExtentReports(String filePath,
Boolean replaceExisting,
DisplayOrder displayOrder,
NetworkMode networkMode,
Locale locale)
Initializes a localized version of Extent HTML report
|
ExtentReports(String filePath,
Boolean replaceExisting,
Locale locale)
Initializes a localized version of Extent HTML report.
|
ExtentReports(String filePath,
Boolean replaceExisting,
NetworkMode networkMode)
Initializes Extent HTML report
Default setting
DisplayOrder.OLDEST_FIRST is used for DisplayOrder
|
ExtentReports(String filePath,
Boolean replaceExisting,
NetworkMode networkMode,
Locale locale)
Initializes a localized version of Extent HTML report.
|
ExtentReports(String filePath,
Locale locale)
Initializes a localized version of Extent HTML report.
|
ExtentReports(String filePath,
NetworkMode networkMode)
Initializes Extent HTML report
Default setting (true) is used for replaceExisting
Default setting
DisplayOrder.OLDEST_FIRST is used for DisplayOrder
|
Modifier and Type | Method and Description |
---|---|
ExtentReports |
addSystemInfo(Map<String,String> info)
Add system information to the SystemInfo view
|
ExtentReports |
addSystemInfo(String param,
String value)
Add system information to the SystemInfo view
|
ExtentReports |
assignProject(String name)
Assign a project name to the report
|
protected void |
attach(IReporter reporter) |
void |
close()
Closes the underlying stream and clears all resources
|
HTMLReporter.Config |
config()
Deprecated.
|
protected void |
convertUpdateLastRunDuration() |
protected void |
detach(IReporter reporter) |
void |
endTest(ExtentTest extentTest)
Ends and prepares the test to be added to the report on
flush() |
protected void |
finalizeTest(Test test) |
void |
flush()
Appends the HTML file with all the ended tests.
|
protected Map<String,List<Test>> |
getCategoryTestMap() |
protected Map<String,String> |
getConfigurationMap() |
protected Test |
getCurrentTest() |
protected DisplayOrder |
getDisplayOrder() |
protected Locale |
getDocumentLocale() |
protected Map<String,List<ExceptionInfo>> |
getExceptionTestMap() |
protected String |
getFilePath() |
protected UUID |
getId() |
protected List<LogStatus> |
getLogStatusList() |
String |
getMongoDBObjectID() |
protected NetworkMode |
getNetworkMode() |
String |
getProjectName() |
protected Boolean |
getReplaceExisting() |
UUID |
getReportId()
Gets the UUID of the report
|
protected String |
getRunDuration() |
protected String |
getRunDurationOverall() |
protected Date |
getStartedTime() |
protected LogStatus |
getStatus() |
protected SuiteTimeInfo |
getSuiteTimeInfo() |
protected com.relevantcodes.extentreports.SystemInfo |
getSystemInfo() |
protected Map<String,String> |
getSystemInfoMap() |
protected List<ExtentTest> |
getTestList() |
protected List<String> |
getTestRunnerLogList() |
void |
loadConfig(Class clazz,
String fileName)
Allows performing configuration and customization to the HTML report from local resource
|
void |
loadConfig(Class clazz,
String basePackagePath,
String fileName)
Allows performing configuration and customization to the HTML report from local resource.
|
protected Map<String,String> |
loadConfig(Configuration config) |
void |
loadConfig(File configFile)
Allows performing configuration and customization to the HTML report from
configuration external file
|
void |
loadConfig(URL url)
Allows performing configuration and customization to the HTML report from URL resource
|
protected void |
setDisplayOrder(DisplayOrder displayOrder) |
protected void |
setDocumentLocale(Locale locale) |
protected void |
setFilePath(String filePath) |
protected void |
setMongoDBObjectID(String id) |
protected void |
setNetworkMode(NetworkMode networkMode) |
protected void |
setProjectName(String name) |
protected void |
setReplaceExisting(Boolean replaceExisting) |
protected void |
setStartedTime(long startTime) |
protected void |
setTestRunnerLogs(String logs) |
void |
setTestRunnerOutput(String log)
Adds logs from test framework tools such as TestNG
|
ExtentReports |
startReporter(ReporterType reporterType,
String filePath)
Starts a custom reporter based upon
ReporterType . |
ExtentTest |
startTest(String testName)
Calling startTest() generates a toggle for the test in the HTML file and adds all
log events under this level.
|
ExtentTest |
startTest(String testName,
String description)
Calling startTest() generates a toggle for the test in the HTML file and adds all
log events under this level.
|
protected void |
terminate() |
protected void |
updateTestQueue(ExtentTest extentTest) |
void |
x()
Initializes ExtentX and connects to MongoDB using default host (localhost) and
port (27017)
|
void |
x(List<com.mongodb.ServerAddress> seeds)
Initializes ExtentX and connects to MongoDB.
|
void |
x(List<com.mongodb.ServerAddress> seeds,
List<com.mongodb.MongoCredential> credentialsList)
Initializes ExtentX and connects to MongoDB.
|
void |
x(List<com.mongodb.ServerAddress> seeds,
List<com.mongodb.MongoCredential> credentialsList,
com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB based on a list of replica set
members or a list of mongos
|
void |
x(List<com.mongodb.ServerAddress> seeds,
com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB
|
void |
x(com.mongodb.MongoClientURI uri)
Initializes ExtentX and connects to MongoDB described by a URI
|
void |
x(com.mongodb.ServerAddress addr)
Initializes ExtentX and connects to MongoDB
|
void |
x(com.mongodb.ServerAddress addr,
List<com.mongodb.MongoCredential> credentialsList)
Initializes ExtentX and connects to MongoDB
|
void |
x(com.mongodb.ServerAddress addr,
List<com.mongodb.MongoCredential> credentialsList,
com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB
|
void |
x(com.mongodb.ServerAddress addr,
com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB
|
void |
x(String host)
Initializes ExtentX and connects to MongoDB using host and default port (27017)
|
void |
x(String host,
int port)
Initializes ExtentX and connects to MongoDB
|
void |
x(String host,
com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB based on a (single) mongodb
node (default port)
|
getLogDateFormat, getLogDateTimeFormat, getLogTimeFormat, getLongDateTimeFormat, setLogDateFormat, setLogTimeFormat
protected SuiteTimeInfo suiteTimeInfo
protected com.relevantcodes.extentreports.SystemInfo systemInfo
protected List<ExtentTest> testList
protected File configFile
public ExtentReports(String filePath, Boolean replaceExisting, DisplayOrder displayOrder, NetworkMode networkMode, Locale locale)
Initializes a localized version of Extent HTML report
filePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
displayOrder
- Determines the order in which your tests will be displayed
networkMode
- %reportFolder%/extentreports
with the following structure:
locale
- Locale to adapt for the report. All standard text for the report will be displayed
in the selected locale.public ExtentReports(String filePath, Boolean replaceExisting, DisplayOrder displayOrder, NetworkMode networkMode)
Initializes Extent HTML report
filePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
displayOrder
- Determines the order in which your tests will be displayed
networkMode
- %reportFolder%/extentreports
with the following structure:
public ExtentReports(String filePath, Boolean replaceExisting, DisplayOrder displayOrder, Locale locale)
Initializes a localized version of Extent HTML report. To see a list of supported locales, visit: http://extentreports.relevantcodes.com
NetworkMode.ONLINE
for NetworkMode
is usedfilePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
displayOrder
- Determines the order in which your tests will be displayed
locale
- Locale to adapt for the report. All standard text for the report will be displayed
in the selected locale.public ExtentReports(String filePath, Boolean replaceExisting, DisplayOrder displayOrder)
Initializes Extent HTML report
NetworkMode.ONLINE
for NetworkMode
is usedfilePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
displayOrder
- Determines the order in which your tests will be displayed
public ExtentReports(String filePath, Boolean replaceExisting, NetworkMode networkMode, Locale locale)
Initializes a localized version of Extent HTML report. To see a list of supported locales, visit: http://extentreports.relevantcodes.com
DisplayOrder.OLDEST_FIRST
is used for DisplayOrder
filePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
networkMode
- %reportFolder%/extentreports
with the following structure:
locale
- Locale to adapt for the report. All standard text for the report will be displayed
in the selected locale.public ExtentReports(String filePath, Boolean replaceExisting, NetworkMode networkMode)
Initializes Extent HTML report
DisplayOrder.OLDEST_FIRST
is used for DisplayOrder
filePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
networkMode
- %reportFolder%/extentreports
with the following structure:
public ExtentReports(String filePath, NetworkMode networkMode)
Initializes Extent HTML report
DisplayOrder.OLDEST_FIRST
is used for DisplayOrder
filePath
- Path of the file, in .htm or .html formatnetworkMode
- %reportFolder%/extentreports
with the following structure:
public ExtentReports(String filePath, Boolean replaceExisting, Locale locale)
Initializes a localized version of Extent HTML report. To see a list of supported locales, visit: http://extentreports.relevantcodes.com
Note: a new report will be created by default since replaceExisting
is
true
by default
Examples:
new ExtentReports("filePath", Locale.ENGLISH);
new ExtentReports("filePath", new Locale("es"));
filePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
locale
- Locale to adapt for the report. All standard text for the report will be displayed
in the selected locale.public ExtentReports(String filePath, Boolean replaceExisting)
Initializes Extent HTML report
DisplayOrder.OLDEST_FIRST
is used for DisplayOrder
NetworkMode.ONLINE
for NetworkMode
is usedfilePath
- Path of the file, in .htm or .html formatreplaceExisting
- Setting to overwrite (TRUE) the existing file or append (FALSE) to it
public ExtentReports(String filePath, Locale locale)
Initializes a localized version of Extent HTML report. To see a list of supported locales, visit: http://extentreports.relevantcodes.com
Note: a new report will be created by default since replaceExisting
is
true
by default
Examples:
new ExtentReports("filePath", Locale.ENGLISH);
new ExtentReports("filePath", new Locale("es"));
filePath
- Path of the file, in .htm or .html formatlocale
- Locale to adapt for the report. All standard text for the report will be displayed
in the selected locale.public ExtentReports(String filePath)
Initializes Extent HTML report
DisplayOrder.OLDEST_FIRST
is used for DisplayOrder
NetworkMode.ONLINE
for NetworkMode
is usedfilePath
- Path of the file, in .htm or .html formatpublic ExtentReports assignProject(String name)
Assign a project name to the report
name
- Project namepublic UUID getReportId()
Gets the UUID of the report
Note: Each time an instance of ExtentReports
is created, a unique
UUID is created for that instance automatically. This unique UUID is also stored
in the database (if the database reporter is started).
UUID
public void loadConfig(File configFile)
Allows performing configuration and customization to the HTML report from configuration external file
configFile
- Config file (extent-config.xml)public void loadConfig(URL url)
Allows performing configuration and customization to the HTML report from URL resource
url
- URL pointer to the resource filepublic void loadConfig(Class clazz, String fileName)
Allows performing configuration and customization to the HTML report from local resource
clazz
- The class relative to which the configuration file will be loadedfileName
- Name of the file from the clazz
packagepublic void loadConfig(Class clazz, String basePackagePath, String fileName)
Allows performing configuration and customization to the HTML report from local resource.
Example: Sonsider the following clazz
, basePackagePath
and fileName
:
clazz
: "com/relevantcodes/extentreports/ExtentReports.class"basePackagePath
: "resources"fileName
: "extent-config.xml"The above inputs will build the final path as: "com/relevantcodes/extentreports/resources/extent-config.xml"
clazz
- The class relative to which the configuration file will be loadedbasePackagePath
- The package that contains the configuration file. The basePackagePath is relative
to the clazz
fileName
- Name of the file from the clazz
packagepublic void x()
Initializes ExtentX and connects to MongoDB using default host (localhost) and port (27017)
public void x(String host)
Initializes ExtentX and connects to MongoDB using host and default port (27017)
host
- MongoDB's database's host addresspublic void x(String host, int port)
Initializes ExtentX and connects to MongoDB
host
- The database's host addressport
- The port on which the database is runningpublic void x(com.mongodb.MongoClientURI uri)
Initializes ExtentX and connects to MongoDB described by a URI
Creates a Mongo described by a URI. If only one address is used MongoClient will only connect to that node, otherwise it will discover all nodes
uri
- The URIpublic void x(String host, com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB based on a (single) mongodb node (default port)
host
- The database's host addressoptions
- Default query optionspublic void x(com.mongodb.ServerAddress addr)
Initializes ExtentX and connects to MongoDB
addr
- The database addresspublic void x(List<com.mongodb.ServerAddress> seeds)
Initializes ExtentX and connects to MongoDB. Creates a Mongo based on a list of replica set members or a list of mongos.
seeds
- List of mongod servers in the same replica set or a list of mongos
servers in the same sharded clusterpublic void x(List<com.mongodb.ServerAddress> seeds, List<com.mongodb.MongoCredential> credentialsList)
Initializes ExtentX and connects to MongoDB. Creates a Mongo based on a list of replica set members or a list of mongos.
seeds
- List of mongod servers in the same replica set or a list of mongos
servers in the same sharded clustercredentialsList
- The list of credentials used to authenticate all connectionspublic void x(List<com.mongodb.ServerAddress> seeds, List<com.mongodb.MongoCredential> credentialsList, com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB based on a list of replica set members or a list of mongos
seeds
- List of mongod servers in the same replica set or a list of mongos
servers in the same sharded clustercredentialsList
- The list of credentials used to authenticate all connectionsoptions
- Default optionspublic void x(List<com.mongodb.ServerAddress> seeds, com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB
seeds
- List of mongod servers in the same replica set or a list of mongos
servers in the same sharded clusteroptions
- Default optionspublic void x(com.mongodb.ServerAddress addr, List<com.mongodb.MongoCredential> credentialsList)
Initializes ExtentX and connects to MongoDB
addr
- The database addresscredentialsList
- The list of credentials used to authenticate all connectionspublic void x(com.mongodb.ServerAddress addr, List<com.mongodb.MongoCredential> credentialsList, com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB
addr
- The database addresscredentialsList
- The list of credentials used to authenticate all connectionsoptions
- Default optionspublic void x(com.mongodb.ServerAddress addr, com.mongodb.MongoClientOptions options)
Initializes ExtentX and connects to MongoDB
addr
- The database addressoptions
- Default optionspublic ExtentReports startReporter(ReporterType reporterType, String filePath)
Starts a custom reporter based upon ReporterType
. The file extension determines if
the reporter-type will be started.
For ReporterType
the extension must be .db
reporterType
- ReporterType
Type of the reporter to be initializedfilePath
- Path of the report source, with the correct extension for the reporterExtentReports
objectpublic ExtentTest startTest(String testName, String description)
Calling startTest() generates a toggle for the test in the HTML file and adds all log events under this level. This is a required step and without calling this method the toggle will not be created for the test and log will not be added.
testName
- Name of the testdescription
- A short description of the testExtentTest
objectpublic ExtentTest startTest(String testName)
Calling startTest() generates a toggle for the test in the HTML file and adds all log events under this level. This is a required step and without calling this method the toggle will not be created for the test and log will not be added.
testName
- Name of the testExtentTest
objectpublic void endTest(ExtentTest extentTest)
Ends and prepares the test to be added to the report on flush()
If ReporterType.DB
is used, a row in the TEST table is created
extentTest
- An ExtentTest
objectpublic ExtentReports addSystemInfo(Map<String,String> info)
Add system information to the SystemInfo view
info
- SystemInfo values as Key-Value pairsExtentReports
objectpublic ExtentReports addSystemInfo(String param, String value)
Add system information to the SystemInfo view
param
- Name of system parametervalue
- Value of system parameterExtentReports
objectpublic void setTestRunnerOutput(String log)
Adds logs from test framework tools such as TestNG
log
- Log string from the TestRunnerpublic void flush()
Appends the HTML file with all the ended tests. There must be at least 1 ended test for anything to be appended to the report.
Note: If flush()
is called before any of the ended tests,
no information will be appended.
Note: If flush()
is called while the test is running (not yet ended),
it will not be appended to the report.
public void close()
Closes the underlying stream and clears all resources
Once close is called, additional information will not be sent to the report. Any
attempt to flush()
will result in a IOException
.
If any of your test ended abruptly causing any side-affects (not all logs sent to ExtentReports, information missing), this method will ensure that the test is still appended to the report with a warning message.
@Deprecated public HTMLReporter.Config config()
This method is deprecated and replace with an external configuration file. For more information, visit this link: http://extentreports.relevantcodes.com/java/version2/docs.html#configuration
protected List<ExtentTest> getTestList()
protected void updateTestQueue(ExtentTest extentTest)
protected Date getStartedTime()
protected String getRunDuration()
protected String getRunDurationOverall()
protected void convertUpdateLastRunDuration()
protected Map<String,List<ExceptionInfo>> getExceptionTestMap()
protected com.relevantcodes.extentreports.SystemInfo getSystemInfo()
protected void attach(IReporter reporter)
protected void detach(IReporter reporter)
protected void finalizeTest(Test test)
protected void terminate()
protected Map<String,String> loadConfig(Configuration config)
protected void setTestRunnerLogs(String logs)
protected Test getCurrentTest()
protected void setFilePath(String filePath)
protected String getFilePath()
protected void setReplaceExisting(Boolean replaceExisting)
protected Boolean getReplaceExisting()
protected void setDisplayOrder(DisplayOrder displayOrder)
protected DisplayOrder getDisplayOrder()
protected void setNetworkMode(NetworkMode networkMode)
protected NetworkMode getNetworkMode()
protected UUID getId()
protected LogStatus getStatus()
protected SuiteTimeInfo getSuiteTimeInfo()
protected void setStartedTime(long startTime)
protected void setDocumentLocale(Locale locale)
protected Locale getDocumentLocale()
protected void setProjectName(String name)
public String getProjectName()
protected void setMongoDBObjectID(String id)
public String getMongoDBObjectID()
Copyright © 2016. All rights reserved.