Package io.cucumber.java
Class Scenario
- java.lang.Object
-
- io.cucumber.java.Scenario
-
@API(status=STABLE) public final class Scenario extends Object
Before or After Hooks that declare a parameter of this type will receive an instance of this class. It allows writing text and embedding media into reports, as well as inspecting results (in an After block).Note: This class is not intended to be used to create reports. To create custom reports use the
io.cucumber.plugin.Plugin
class. The plugin system provides a much richer access to Cucumbers then hooks after could provide. For an example seeio.cucumber.core.plugin.PrettyFormatter
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attach(byte[] data, String mediaType, String name)
Attach data to the report(s).void
attach(String data, String mediaType, String name)
Attaches some text based data to the report.String
getId()
Integer
getLine()
String
getName()
Collection<String>
getSourceTagNames()
Status
getStatus()
Returns the current status of this scenario.URI
getUri()
boolean
isFailed()
void
log(String text)
Outputs some text into the report.
-
-
-
Method Detail
-
getSourceTagNames
public Collection<String> getSourceTagNames()
- Returns:
- tags of this scenario.
-
getStatus
public Status getStatus()
Returns the current status of this scenario.The scenario status is calculate as the most severe status of the executed steps in the scenario so far.
- Returns:
- the current status of this scenario
-
isFailed
public boolean isFailed()
- Returns:
- true if and only if
getStatus()
returns "failed"
-
attach
public void attach(byte[] data, String mediaType, String name)
Attach data to the report(s).// Attach a screenshot. See your UI automation tool's docs for // details about how to take a screenshot. scenario.attach(pngBytes, "image/png", "Bartholomew and the Bytes of the Oobleck");
To ensure reporting tools can understand what the data is a
mediaType
must be provided. For example:text/plain
,image/png
,text/html;charset=utf-8
.Media types are defined in RFC 7231 Section 3.1.1.1.
- Parameters:
data
- what to attach, for example an image.mediaType
- what is the data?name
- attachment name
-
attach
public void attach(String data, String mediaType, String name)
Attaches some text based data to the report.- Parameters:
data
- what to attach, for example html.mediaType
- what is the data?name
- attachment name- See Also:
attach(byte[], String, String)
-
log
public void log(String text)
Outputs some text into the report.- Parameters:
text
- what to put in the report.- See Also:
attach(byte[], String, String)
-
getName
public String getName()
- Returns:
- the name of the Scenario
-
getId
public String getId()
- Returns:
- the id of the Scenario.
-
getUri
public URI getUri()
- Returns:
- the uri of the Scenario.
-
getLine
public Integer getLine()
- Returns:
- the line in the feature file of the Scenario. If this is a Scenario from Scenario Outlines this will return the line of the example row in the Scenario Outline.
-
-