@@ -5,33 +5,101 @@ import java.util
55
66import io .cucumber .core .backend .{Status , TestCaseState }
77
8+ /**
9+ * Before or After Hooks that declare a parameter of this type will receive an instance of this class.
10+ * It allows writing text and embedding media into reports, as well as inspecting results (in an After block).
11+ * <p>
12+ * Note: This class is not intended to be used to create reports. To create custom reports use
13+ * the `io.cucumber.plugin.Plugin` class. The plugin system provides a much richer access to Cucumbers then
14+ * hooks after could provide. For an example see `io.cucumber.core.plugin.PrettyFormatter`.
15+ */
816class Scenario (val delegate : TestCaseState ) {
917
1018 def getSourceTagNames : util.Collection [String ] = delegate.getSourceTagNames
1119
20+ /**
21+ * Returns the current status of this scenario.
22+ * <p>
23+ * The scenario status is calculate as the most severe status of the
24+ * executed steps in the scenario so far.
25+ *
26+ * @return the current status of this scenario
27+ */
1228 def getStatus : Status = Status .valueOf(delegate.getStatus.name)
1329
30+ /**
31+ * @return true if and only if { @link #getStatus()} returns "failed"
32+ */
1433 def isFailed : Boolean = delegate.isFailed
1534
16- @ deprecated
35+ @ deprecated(message = " Use attach instead " )
1736 def embed (data : Array [Byte ], mediaType : String ): Unit = {
1837 delegate.embed(data, mediaType)
1938 }
2039
40+ @ deprecated(message = " Use attach instead" , since = " 5.7.0" )
2141 def embed (data : Array [Byte ], mediaType : String , name : String ): Unit = {
22- delegate.embed (data, mediaType, name)
42+ attach (data, mediaType, name)
2343 }
2444
45+ /**
46+ * Attach data to the report(s).
47+ * <pre>
48+ * {@code
49+ * // Attach a screenshot. See your UI automation tool's docs for
50+ * // details about how to take a screenshot.
51+ * scenario.attach(pngBytes, "image/png", "Bartholomew and the Bytes of the Oobleck");
52+ * }
53+ * </pre>
54+ * <p>
55+ * To ensure reporting tools can understand what the data is a
56+ * {@code mediaType} must be provided. For example: {@code text/plain},
57+ * {@code image/png}, {@code text/html;charset=utf-8}.
58+ * <p>
59+ * Media types are defined in <a href= https://tools.ietf.org/html/rfc7231#section-3.1.1.1>RFC 7231 Section 3.1.1.1</a>.
60+ *
61+ * @param data what to attach, for example an image.
62+ * @param mediaType what is the data?
63+ * @param name attachment name
64+ */
65+ def attach (data : Array [Byte ], mediaType : String , name : String ): Unit = {
66+ delegate.attach(data, mediaType, name)
67+ }
68+
69+ @ deprecated(message = " Use log instead" , since = " 5.7.0" )
2570 def write (text : String ): Unit = {
26- delegate.write(text)
71+ log(text)
72+ }
73+
74+ /**
75+ * Outputs some text into the report.
76+ *
77+ * @param text what to put in the report.
78+ */
79+ def log (text : String ): Unit = {
80+ delegate.log(text)
2781 }
2882
83+ /**
84+ * @return the name of the Scenario
85+ */
2986 def getName : String = delegate.getName
3087
88+ /**
89+ * @return the id of the Scenario.
90+ */
3191 def getId : String = delegate.getId
3292
93+ /**
94+ * @return the uri of the Scenario.
95+ */
3396 def getUri : URI = delegate.getUri
3497
98+ /**
99+ * @return the line in the feature file of the Scenario. If this is a Scenario
100+ * from Scenario Outlines this will return the line of the example row in
101+ * the Scenario Outline.
102+ */
35103 def getLine : Integer = delegate.getLine
36104
37105}
0 commit comments