public class ExtentTest extends Object implements IExtentTestClass
Defines a node in the report file.
By default, each started node is top-level. If appendChild
method
is used on any test, it automatically becomes a child-node. When this happens:
hasChildNodes = true
isChildNode = true
Constructor and Description |
---|
ExtentTest(String testName,
String description)
Creates a test node as a top-most level test
|
Modifier and Type | Method and Description |
---|---|
String |
addBase64ScreenShot(String base64)
Adds a snapshot to the log event details using a Base64 string
|
String |
addScreenCapture(String imagePath)
Adds a snapshot to the log event details
|
String |
addScreencast(String screencastPath)
Adds a screen cast to the log event details
|
ExtentTest |
appendChild(ExtentTest node)
Appends a child test (another
ExtentTest ) to the current test |
ExtentTest |
assignAuthor(String... authors)
Assigns author(s) to test
|
ExtentTest |
assignCategory(String... categories)
Assigns category to test
|
String |
getDescription()
Gets the current test description
|
Date |
getEndedTime()
Provides the end time of the current test
|
LogStatus |
getRunStatus()
Provides the current run status of the test
|
Date |
getStartedTime()
Provides the start time of the current test
|
ITest |
getTest()
Returns the interface that exposes some important methods of the underlying test
|
void |
log(LogStatus logStatus,
String details)
Logs events for the test
|
void |
log(LogStatus logStatus,
String stepName,
String details)
Logs events for the test
|
void |
log(LogStatus logStatus,
String stepName,
Throwable t)
Logs events for the test
|
void |
log(LogStatus logStatus,
Throwable t)
Logs events for the test
|
void |
setDescription(String description)
Sets the current test description
|
void |
setEndedTime(Date endedTime)
Allows overriding the default end time of the test
|
void |
setStartedTime(Date startedTime)
Allows overriding the default start time of the test
|
public void log(LogStatus logStatus, String stepName, String details)
Logs events for the test
Log event is shown in the report with 4 columns:
log
in interface IExtentTestClass
logStatus
- Status (see LogStatus
)stepName
- Name of the stepdetails
- Details of the steppublic void log(LogStatus logStatus, String stepName, Throwable t)
Logs events for the test
Log event is shown in the report with 4 columns:
log
in interface IExtentTestClass
logStatus
- Status (see LogStatus
)stepName
- Name of the stept
- Exceptionpublic void log(LogStatus logStatus, Throwable t)
Logs events for the test
Log event is shown in the report with 3 columns:
log
in interface IExtentTestClass
logStatus
- Status (see LogStatus
)t
- Exceptionpublic void log(LogStatus logStatus, String details)
Logs events for the test
Log event is shown in the report with 3 columns:
log
in interface IExtentTestClass
logStatus
- Status (see LogStatus
)details
- Details of the steppublic void setDescription(String description)
Sets the current test description
setDescription
in interface IExtentTestClass
description
- Description of the testpublic String getDescription()
Gets the current test description
getDescription
in interface IExtentTestClass
public Date getStartedTime()
Provides the start time of the current test
getStartedTime
in interface IExtentTestClass
public void setStartedTime(Date startedTime)
Allows overriding the default start time of the test
Note: when a test is started using extent.startTest(testName)
,
the value for started time is created automatically. This method allows
overriding the start time in cases where the actual test had already been
run prior to extent logging the test details in the report. An example of
this scenario is while using TestNG's IReporter
listener and
creating the report after the tests have already executed.
setStartedTime
in interface IExtentTestClass
startedTime
- Test's start timepublic Date getEndedTime()
Provides the end time of the current test
getEndedTime
in interface IExtentTestClass
public void setEndedTime(Date endedTime)
Allows overriding the default end time of the test
Note: when a test is ended using extent.endTest(extentTest)
,
the value for ended time is created automatically. This method allows
overriding the end time in cases where the actual test had already been
run prior to extent logging the test details in the report. An example of
this scenario is while using TestNG's IReporter
listener and
creating the report after the tests have already executed.
setEndedTime
in interface IExtentTestClass
endedTime
- Test's end timepublic String addScreenCapture(String imagePath)
Adds a snapshot to the log event details
Note: this method does not create the screen-capture for the report, it only sets the path of the image file in the report. The user is responsible for capturing the screen and for constructing the path to the image file.
addScreenCapture
in interface IExtentTestClass
imagePath
- Path of the image in relation to where your report residespublic String addBase64ScreenShot(String base64)
Adds a snapshot to the log event details using a Base64 string
addBase64ScreenShot
in interface IExtentTestClass
base64
- Base64 image stringpublic String addScreencast(String screencastPath)
Adds a screen cast to the log event details
Note: this method does not attach the screen-cast to the report, it only links to the path
addScreencast
in interface IExtentTestClass
screencastPath
- Path of the screencastpublic ExtentTest assignCategory(String... categories)
Assigns category to test
Usage: test.assignCategory("ExtentAPI");
Usage: test.assignCategory("ExtentAPI", "Regression", ...);
assignCategory
in interface IExtentTestClass
categories
- Category nameExtentTest
objectpublic ExtentTest assignAuthor(String... authors)
Assigns author(s) to test
Usage: test.assignAuthor("AuthorName");
Usage: test.assignAuthor("Author1", "Author2", ...);
assignAuthor
in interface IExtentTestClass
authors
- Author nameExtentTest
public ExtentTest appendChild(ExtentTest node)
Appends a child test (another ExtentTest
) to the current test
appendChild
in interface IExtentTestClass
node
- An ExtentTest
object. Test that is added as the node.ExtentTest
object. Parent test which adds the node as its child.public LogStatus getRunStatus()
Provides the current run status of the test
getRunStatus
in interface IExtentTestClass
LogStatus
public ITest getTest()
Returns the interface that exposes some important methods of the underlying test
getTest
in interface IExtentTestClass
ITest
objectCopyright © 2016. All rights reserved.