Package com.aventstack.extentreports
Class ExtentTest
java.lang.Object
com.aventstack.extentreports.ExtentTest
- All Implemented Interfaces:
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:
-
Method Summary
Modifier and TypeMethodDescriptionaddScreenCaptureFromBase64String(String base64, String title) addScreenCaptureFromPath(String path, String title) assignAuthor(String... author) Assigns an authorassignCategory(String... category) Assigns a category or groupassignDevice(String... device) Assign a devicecreateNode(GherkinKeyword gherkinKeyword, String name) createNode(GherkinKeyword gherkinKeyword, String name, String description) createNode(Class<? extends IGherkinFormatterModel> type, String name) Creates a BDD-style node representing one of theIGherkinFormatterModelclasses such as:FeatureBackgroundScenarioGivenWhenThenAndcreateNode(Class<? extends IGherkinFormatterModel> type, String name, String description) Creates a BDD-style node with description representing one of theIGherkinFormatterModelclasses:FeatureBackgroundScenarioGivenWhenThenAndcreateNode(String name) Creates a nodecreateNode(String name, String description) Creates a node with descriptionLogs an event withStatus.FAILand customMarkupsuch as: Code block Label TableLogs an event withStatus.FAILandScreenCaptureLogs an eventStatus.FAILwith detailsLogs anStatus.FAILevent with details and a media object:ScreenCaptureLogs an event withStatus.FAILand exceptionLogs anStatus.FAILevent with an exception and a media object:ScreenCapturegenerateLog(Status status, Markup markup) Create a non-standard log with details.generateLog(Status status, String details) Create a non-standard log with details.Logs an event withStatus.INFOand customMarkupsuch as: Code block Label TableLogs an event withStatus.INFOandScreenCaptureLogs an event withStatus.INFOwith detailsLogs anStatus.INFOevent with details and a media object:ScreenCaptureLogs an event withStatus.INFOand exceptionLogs anStatus.INFOevent with an exception and a media object:ScreenCaptureLogs an event withStatus, details and a media object:ScreenCaptureLogs an event withStatusand detailsLogs an event withStatus, details and a media object:ScreenCaptureLogs an event withStatus, details and a media object:ScreenCaptureLogs an event withStatusand exceptionLogs an event withStatus, an exception and a media object:ScreenCaptureLogs an event withStatus.PASSand customMarkupsuch as: Code block Label TableLogs an event withStatus.PASSandScreenCaptureLogs an eventStatus.PASSwith detailsLogs anStatus.PASSevent with details and a media object:ScreenCaptureLogs an event withStatus.PASSand exceptionLogs anStatus.PASSevent with an exception and a media object:ScreenCaptureLogs an event withStatus.SKIPand customMarkupsuch as: Code block Label TableLogs an event withStatus.SKIPandScreenCaptureLogs an eventStatus.SKIPwith detailsLogs an event withStatus.SKIPand exceptionLogs anStatus.SKIPevent with an exception and a media object:ScreenCaptureLogs an event withStatus.WARNINGand customMarkupsuch as: Code block Label TableLogs an event withStatus.WARNINGandScreenCaptureLogs an eventStatus.WARNINGwith detailsLogs anStatus.WARNINGevent with an exception and a media object:ScreenCaptureLogs an event withStatus.WARNINGand exceptionLogs anStatus.WARNINGevent with an exception and a media object:ScreenCapture
-
Method Details
-
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
Creates a node with description- Parameters:
name- Name of nodedescription- A short description- Returns:
ExtentTestobject
-
createNode
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
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
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
Creates a node- Parameters:
name- Name of node- Returns:
ExtentTestobject
-
generateLog
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
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
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
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
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
Logs an event withStatusand details- Parameters:
status-Statusdetails- Details- Returns:
- An
ExtentTestobject
-
log
- Parameters:
status-Statusmarkup-Markupmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
log
- Parameters:
status-Statusmarkup-Markup- Returns:
- An
ExtentTestobject
-
log
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
Logs an event withStatusand exception- Parameters:
status-Statust-Throwable- Returns:
- An
ExtentTestobject
-
info
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
Logs an event withStatus.INFOwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
info
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
Logs an event withStatus.INFOand exception- Parameters:
t- AThrowableexception to be logged, enabling the Exception view of certain HTML reporters- Returns:
ExtentTestobject
-
info
- Parameters:
m-Markup- Returns:
ExtentTestobject
-
info
Logs an event withStatus.INFOandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
pass
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
Logs an eventStatus.PASSwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
pass
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
Logs an event withStatus.PASSand exception- Parameters:
t-Throwable- Returns:
- An
ExtentTestobject
-
pass
- Parameters:
m-Markup- Returns:
- An
ExtentTestobject
-
pass
Logs an event withStatus.PASSandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
fail
Logs anStatus.FAILevent with details and a media object:ScreenCapture- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
fail
Logs an eventStatus.FAILwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
fail
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
Logs an event withStatus.FAILand exception- Parameters:
t-Throwable- Returns:
ExtentTestobject
-
fail
- Parameters:
m-Markup- Returns:
ExtentTestobject
-
fail
Logs an event withStatus.FAILandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
warning
Logs anStatus.WARNINGevent with an exception and a media object:ScreenCapture- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
warning
Logs an eventStatus.WARNINGwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
warning
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
Logs an event withStatus.WARNINGand exception- Parameters:
t-Throwable- Returns:
ExtentTestobject
-
warning
- Parameters:
m-Markup- Returns:
- An
ExtentTestobject
-
warning
Logs an event withStatus.WARNINGandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
skip
- Parameters:
details- Detailsmedia- AMediaobject provided byMediaEntityBuilder- Returns:
- An
ExtentTestobject
-
skip
Logs an eventStatus.SKIPwith details- Parameters:
details- Details- Returns:
ExtentTestobject
-
skip
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
Logs an event withStatus.SKIPand exception- Parameters:
t-Throwable- Returns:
ExtentTestobject
-
skip
- Parameters:
m-Markup- Returns:
ExtentTestobject
-
skip
Logs an event withStatus.SKIPandScreenCapture- Parameters:
media- AMediaobject provided byMediaEntityBuilder- Returns:
ExtentTestobject
-
assignCategory
Assigns a category or group- Parameters:
category- Category name- Returns:
ExtentTestobject
-
assignAuthor
Assigns an author- Parameters:
author- Author name- Returns:
ExtentTestobject
-
assignDevice
Assign a device- Parameters:
device- Device name- Returns:
ExtentTestobject
-
getStatus
-
addScreenCaptureFromPath
-
addScreenCaptureFromPath
-
addScreenCaptureFromBase64String
-
addScreenCaptureFromBase64String
-