Package com.aventstack.extentreports
Class ExtentTest
- java.lang.Object
-
- com.aventstack.extentreports.ExtentTest
-
- All Implemented Interfaces:
RunResult,Serializable
public class ExtentTest extends Object implements RunResult, Serializable
Defines a test. You can add logs, snapshots, assign author and categories to a test and its children.The below log types will all be logged with
Status.PASS:test.log(Status.PASS, "details"); test.pass("details"); test.pass(MarkupHelper.createCodeBlock(code));A few notes:
- Tests started with the
createTestmethod are parent-level, always level 0 - Tests started with the
createNodemethod are children, always level 1 and greater
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExtentTestaddMedia(Media m)ExtentTestaddScreenCaptureFromBase64String(String base64)ExtentTestaddScreenCaptureFromBase64String(String base64, String title)ExtentTestaddScreenCaptureFromPath(String path)ExtentTestaddScreenCaptureFromPath(String path, String title)ExtentTestaddVideoFromBase64String(String base64)ExtentTestaddVideoFromBase64String(String base64, String title)ExtentTestaddVideoFromPath(String path)ExtentTestaddVideoFromPath(String path, String title)ExtentTestassignAuthor(String... author)Assigns an authorExtentTestassignCategory(String... category)Assigns a category or groupExtentTestassignDevice(String... device)Assign a deviceExtentTestcreateNode(GherkinKeyword gherkinKeyword, String name)ExtentTestcreateNode(GherkinKeyword gherkinKeyword, String name, String description)ExtentTestcreateNode(Class<? extends IGherkinFormatterModel> type, String name)Creates a BDD-style node representing one of theIGherkinFormatterModelclasses such as:FeatureBackgroundScenarioGivenWhenThenAndExtentTestcreateNode(Class<? extends IGherkinFormatterModel> type, String name, String description)Creates a BDD-style node with description representing one of theIGherkinFormatterModelclasses:FeatureBackgroundScenarioGivenWhenThenAndExtentTestcreateNode(String name)Creates a nodeExtentTestcreateNode(String name, String description)Creates a node with descriptionExtentTestfail(Markup m)Logs an event withStatus.FAILand customMarkupsuch as: Code block Label TableExtentTestfail(Media media)Logs an event withStatus.FAILandScreenCaptureExtentTestfail(String details)Logs an eventStatus.FAILwith detailsExtentTestfail(String details, Media media)Logs anStatus.FAILevent with details and a media object:ScreenCaptureExtentTestfail(Throwable t)Logs an event withStatus.FAILand exceptionExtentTestfail(Throwable t, Media media)Logs anStatus.FAILevent with an exception and a media object:ScreenCaptureExtentTestgenerateLog(Status status, Markup markup)Create a non-standard log with details.ExtentTestgenerateLog(Status status, String details)Create a non-standard log with details.StatusgetStatus()ExtentTestinfo(Markup m)Logs an event withStatus.INFOand customMarkupsuch as: Code block Label TableExtentTestinfo(Media media)Logs an event withStatus.INFOandScreenCaptureExtentTestinfo(String details)Logs an event withStatus.INFOwith detailsExtentTestinfo(String details, Media media)Logs anStatus.INFOevent with details and a media object:ScreenCaptureExtentTestinfo(Throwable t)Logs an event withStatus.INFOand exceptionExtentTestinfo(Throwable t, Media media)Logs anStatus.INFOevent with an exception and a media object:ScreenCaptureExtentTestlog(Status status, Markup markup)ExtentTestlog(Status status, Markup markup, Media media)ExtentTestlog(Status status, Media media)Logs an event withStatus, details and a media object:ScreenCaptureExtentTestlog(Status status, String details)Logs an event withStatusand detailsExtentTestlog(Status status, String details, Media media)Logs an event withStatus, details and a media object:ScreenCaptureExtentTestlog(Status status, String details, Throwable t, Media media)Logs an event withStatus, details and a media object:ScreenCaptureExtentTestlog(Status status, Throwable t)Logs an event withStatusand exceptionExtentTestlog(Status status, Throwable t, Media media)Logs an event withStatus, an exception and a media object:ScreenCaptureExtentTestpass(Markup m)Logs an event withStatus.PASSand customMarkupsuch as: Code block Label TableExtentTestpass(Media media)Logs an event withStatus.PASSandScreenCaptureExtentTestpass(String details)Logs an eventStatus.PASSwith detailsExtentTestpass(String details, Media media)Logs anStatus.PASSevent with details and a media object:ScreenCaptureExtentTestpass(Throwable t)Logs an event withStatus.PASSand exceptionExtentTestpass(Throwable t, Media media)Logs anStatus.PASSevent with an exception and a media object:ScreenCaptureExtentTestskip(Markup m)Logs an event withStatus.SKIPand customMarkupsuch as: Code block Label TableExtentTestskip(Media media)Logs an event withStatus.SKIPandScreenCaptureExtentTestskip(String details)Logs an eventStatus.SKIPwith detailsExtentTestskip(String details, Media media)ExtentTestskip(Throwable t)Logs an event withStatus.SKIPand exceptionExtentTestskip(Throwable t, Media media)Logs anStatus.SKIPevent with an exception and a media object:ScreenCaptureExtentTestwarning(Markup m)Logs an event withStatus.WARNINGand customMarkupsuch as: Code block Label TableExtentTestwarning(Media media)Logs an event withStatus.WARNINGandScreenCaptureExtentTestwarning(String details)Logs an eventStatus.WARNINGwith detailsExtentTestwarning(String details, Media media)Logs anStatus.WARNINGevent with an exception and a media object:ScreenCaptureExtentTestwarning(Throwable t)Logs an event withStatus.WARNINGand exceptionExtentTestwarning(Throwable t, Media media)Logs anStatus.WARNINGevent with an exception and a media object:ScreenCapture
-
-
-
Method Detail
-
createNode
public ExtentTest createNode(Class<? extends IGherkinFormatterModel> type, String name, String description)
Creates a BDD-style node with description representing one of theIGherkinFormatterModelclasses:Example:
test.createNode(Scenario.class, "bddNode", "description");
- Parameters:
type- AIGherkinFormatterModeltypename- Name of nodedescription- A short description- Returns:
ExtentTestobject
-
createNode
public ExtentTest createNode(String name, String description)
Creates a node with description- Parameters:
name- Name of nodedescription- A short description- Returns:
ExtentTestobject
-
createNode
public ExtentTest createNode(Class<? extends IGherkinFormatterModel> type, String name)
Creates a BDD-style node representing one of theIGherkinFormatterModelclasses such as:Example:
test.createNode(Scenario.class, "bddNode");
- Parameters:
type- AIGherkinFormatterModeltypename- Name of node- Returns:
ExtentTestobject
-
createNode
public ExtentTest createNode(GherkinKeyword gherkinKeyword, String name, String description)
Creates a BDD-style node with description using name of the Gherkin model such as:Example:
test.createNode(new GherkinKeyword("Scenario"), "bddTest", "description");- Parameters:
gherkinKeyword- Name of theGherkinKeywordname- Name of nodedescription- A short description- Returns:
ExtentTest
-
createNode
public ExtentTest createNode(GherkinKeyword gherkinKeyword, String name)
Creates a BDD-style node using name of the Gherkin model such as:Example:
test.createNode(new GherkinKeyword("Scenario"), "bddTest");- Parameters:
gherkinKeyword- Name of theGherkinKeywordname- Name of node- Returns:
ExtentTestobject
-
createNode
public ExtentTest createNode(String name)
Creates a node- Parameters:
name- Name of node- Returns:
ExtentTestobject
-
generateLog
public ExtentTest generateLog(Status status, String details)
Create a non-standard log with details. This is unlike thelogmethod, which creates a fixed table layout with the following columns:- Timestamp
- Status
- Details
- Parameters:
status-Statusdetails- Text details of the step- Returns:
- an
ExtentTestobject
-
generateLog
public ExtentTest generateLog(Status status, Markup markup)
Create a non-standard log with details. This is unlike thelogmethod, which creates a fixed table layout with the following columns:- Timestamp
- Status
- Details
generateLogwithMarkupallows for a user-defined log with any type of markup supported byMarkupHelper.- Parameters:
status-Statusmarkup- AMarkupcreated byMarkupHelper- Returns:
- an
ExtentTestobject
-
log
public ExtentTest log(Status status, String details, Throwable t, Media media)
Logs an event withStatus, details and a media object:ScreenCaptureExample:
test.log(Status.FAIL, "details", MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
status-Statusdetails- Detailst- AThrowableexception to be logged, enabling the Exception view of certain HTML reportersmedia- AMediaobject- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, String details, Media media)
Logs an event withStatus, details and a media object:ScreenCaptureExample:
test.log(Status.FAIL, "details", MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
status-Statusdetails- Detailsmedia- AMediaobject- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, Media media)
Logs an event withStatus, details and a media object:ScreenCaptureExample:
test.log(Status.FAIL, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
status-Statusmedia- AMediaobject- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, String details)
Logs an event withStatusand details- Parameters:
status-Statusdetails- Details- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, Markup markup, Media media)
- Parameters:
status-Statusmarkup-Markupmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, Markup markup)
- Parameters:
status-Statusmarkup-Markup- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, Throwable t, Media media)
Logs an event withStatus, an exception and a media object:ScreenCaptureExample:
Exception exception = new NullPointerException(); test.log(Status.FAIL, exception, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
status-Statust-Throwablemedia- AMediaobject- Returns:
- An
ExtentTestobject
-
log
public ExtentTest log(Status status, Throwable t)
Logs an event withStatusand exception- Parameters:
status-Statust-Throwable- Returns:
- An
ExtentTestobject
-
info
public ExtentTest info(String details, Media media)
Logs anStatus.INFOevent with details and a media object:ScreenCaptureExample:
test.info("details", MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
info
public ExtentTest info(String details)
Logs an event withStatus.INFOwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
info
public ExtentTest info(Throwable t, Media media)
Logs anStatus.INFOevent with an exception and a media object:ScreenCaptureExample:
Exception exception = new NullPointerException(); test.info(exception, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
t- AThrowableexception to be logged, enabling the Exception view of certain HTML reportersmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
info
public ExtentTest info(Throwable t)
Logs an event withStatus.INFOand exception- Parameters:
t- AThrowableexception to be logged, enabling the Exception view of certain HTML reporters- Returns:
ExtentTestobject
-
info
public ExtentTest info(Markup m)
- Parameters:
m-Markup- Returns:
ExtentTestobject
-
info
public ExtentTest info(Media media)
Logs an event withStatus.INFOandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
pass
public ExtentTest pass(String details, Media media)
Logs anStatus.PASSevent with details and a media object:ScreenCaptureExample:
test.pass("details", MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
pass
public ExtentTest pass(String details)
Logs an eventStatus.PASSwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
pass
public ExtentTest pass(Throwable t, Media media)
Logs anStatus.PASSevent with an exception and a media object:ScreenCaptureExample:
Exception exception = new NullPointerException(); test.pass(exception, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
t-Throwablemedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
pass
public ExtentTest pass(Throwable t)
Logs an event withStatus.PASSand exception- Parameters:
t-Throwable- Returns:
- An
ExtentTestobject
-
pass
public ExtentTest pass(Markup m)
- Parameters:
m-Markup- Returns:
- An
ExtentTestobject
-
pass
public ExtentTest pass(Media media)
Logs an event withStatus.PASSandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
fail
public ExtentTest fail(String details, Media media)
Logs anStatus.FAILevent with details and a media object:ScreenCapture- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
fail
public ExtentTest fail(String details)
Logs an eventStatus.FAILwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
fail
public ExtentTest fail(Throwable t, Media media)
Logs anStatus.FAILevent with an exception and a media object:ScreenCaptureExample:
Exception exception = new NullPointerException(); test.fail(exception, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
t-Throwablemedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
fail
public ExtentTest fail(Throwable t)
Logs an event withStatus.FAILand exception- Parameters:
t-Throwable- Returns:
ExtentTestobject
-
fail
public ExtentTest fail(Markup m)
- Parameters:
m-Markup- Returns:
ExtentTestobject
-
fail
public ExtentTest fail(Media media)
Logs an event withStatus.FAILandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
warning
public ExtentTest warning(String details, Media media)
Logs anStatus.WARNINGevent with an exception and a media object:ScreenCapture- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
warning
public ExtentTest warning(String details)
Logs an eventStatus.WARNINGwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
warning
public ExtentTest warning(Throwable t, Media media)
Logs anStatus.WARNINGevent with an exception and a media object:ScreenCaptureExample:
Exception exception = new NullPointerException(); test.warning(exception, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
t-Throwablemedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
warning
public ExtentTest warning(Throwable t)
Logs an event withStatus.WARNINGand exception- Parameters:
t-Throwable- Returns:
ExtentTestobject
-
warning
public ExtentTest warning(Markup m)
- Parameters:
m-Markup- Returns:
- An
ExtentTestobject
-
warning
public ExtentTest warning(Media media)
Logs an event withStatus.WARNINGandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
skip
public ExtentTest skip(String details, Media media)
- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
skip
public ExtentTest skip(String details)
Logs an eventStatus.SKIPwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
skip
public ExtentTest skip(Throwable t, Media media)
Logs anStatus.SKIPevent with an exception and a media object:ScreenCaptureExample:
Exception exception = new NullPointerException(); test.skip(exception, MediaEntityBuilder.createScreenCaptureFromPath("screen.png").build());- Parameters:
t-Throwablemedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
skip
public ExtentTest skip(Throwable t)
Logs an event withStatus.SKIPand exception- Parameters:
t-Throwable- Returns:
ExtentTestobject
-
skip
public ExtentTest skip(Markup m)
- Parameters:
m-Markup- Returns:
ExtentTestobject
-
skip
public ExtentTest skip(Media media)
Logs an event withStatus.SKIPandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
assignCategory
public ExtentTest assignCategory(String... category)
Assigns a category or group- Parameters:
category- Category name- Returns:
ExtentTestobject
-
assignAuthor
public ExtentTest assignAuthor(String... author)
Assigns an author- Parameters:
author- Author name- Returns:
ExtentTestobject
-
assignDevice
public ExtentTest assignDevice(String... device)
Assign a device- Parameters:
device- Device name- Returns:
ExtentTestobject
-
addScreenCaptureFromPath
public ExtentTest addScreenCaptureFromPath(String path, String title)
-
addScreenCaptureFromPath
public ExtentTest addScreenCaptureFromPath(String path)
-
addScreenCaptureFromBase64String
public ExtentTest addScreenCaptureFromBase64String(String base64, String title)
-
addScreenCaptureFromBase64String
public ExtentTest addScreenCaptureFromBase64String(String base64)
-
addVideoFromPath
public ExtentTest addVideoFromPath(String path, String title)
-
addVideoFromPath
public ExtentTest addVideoFromPath(String path)
-
addVideoFromBase64String
public ExtentTest addVideoFromBase64String(String base64, String title)
-
addVideoFromBase64String
public ExtentTest addVideoFromBase64String(String base64)
-
addMedia
public ExtentTest addMedia(Media m)
-
-