1
1
package io .cucumber .core .plugin ;
2
2
3
+ import io .cucumber .plugin .event .Location ;
3
4
import io .cucumber .plugin .event .Status ;
5
+ import io .cucumber .plugin .event .TestCase ;
6
+ import io .cucumber .plugin .event .TestStep ;
4
7
import org .junit .jupiter .api .Test ;
5
8
6
9
import java .io .ByteArrayOutputStream ;
7
10
import java .io .PrintStream ;
11
+ import java .net .URI ;
8
12
import java .time .Instant ;
13
+ import java .util .Collections ;
14
+ import java .util .List ;
9
15
import java .util .Locale ;
16
+ import java .util .UUID ;
10
17
11
18
import static java .time .Duration .ofHours ;
12
19
import static java .time .Duration .ofMillis ;
@@ -46,7 +53,7 @@ void should_only_print_sub_counts_if_not_zero() {
46
53
counter .addStep (Status .PASSED );
47
54
counter .addStep (Status .PASSED );
48
55
counter .addStep (Status .PASSED );
49
- counter .addScenario (Status .PASSED , " scenario designation" );
56
+ counter .addScenario (Status .PASSED , createTestCase ( "classpath:com/example" , 42 , " scenario designation") );
50
57
counter .printStats (new PrintStream (baos ));
51
58
52
59
assertThat (baos .toString (), startsWith (String .format (
@@ -74,7 +81,7 @@ void should_print_sub_counts_in_order_failed_ambiguous_skipped_pending_undefined
74
81
75
82
private void addOneStepScenario (Stats counter , Status status ) {
76
83
counter .addStep (status );
77
- counter .addScenario (status , " scenario designation" );
84
+ counter .addScenario (status , createTestCase ( "classpath:com/example" , 14 , " scenario designation") );
78
85
}
79
86
80
87
@ Test
@@ -174,13 +181,13 @@ void should_print_failed_ambiguous_scenarios() {
174
181
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
175
182
176
183
counter .addStep (Status .FAILED );
177
- counter .addScenario (Status .FAILED , "path/file.feature:3 # Scenario: scenario_name" );
184
+ counter .addScenario (Status .FAILED , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
178
185
counter .addStep (Status .AMBIGUOUS );
179
- counter .addScenario (Status .AMBIGUOUS , "path/file.feature:3 # Scenario: scenario_name" );
186
+ counter .addScenario (Status .AMBIGUOUS , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
180
187
counter .addStep (Status .UNDEFINED );
181
- counter .addScenario (Status .UNDEFINED , "path/file.feature:3 # Scenario: scenario_name" );
188
+ counter .addScenario (Status .UNDEFINED , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
182
189
counter .addStep (Status .PENDING );
183
- counter .addScenario (Status .PENDING , "path/file.feature:3 # Scenario: scenario_name" );
190
+ counter .addScenario (Status .PENDING , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
184
191
counter .printStats (new PrintStream (baos ));
185
192
186
193
assertThat (baos .toString (), startsWith (String .format ("" +
@@ -205,13 +212,13 @@ void should_print_failed_ambiguous_pending_undefined_scenarios_if_strict() {
205
212
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
206
213
207
214
counter .addStep (Status .FAILED );
208
- counter .addScenario (Status .FAILED , "path/file.feature:3 # Scenario: scenario_name" );
215
+ counter .addScenario (Status .FAILED , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
209
216
counter .addStep (Status .AMBIGUOUS );
210
- counter .addScenario (Status .AMBIGUOUS , "path/file.feature:3 # Scenario: scenario_name" );
217
+ counter .addScenario (Status .AMBIGUOUS , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
211
218
counter .addStep (Status .UNDEFINED );
212
- counter .addScenario (Status .UNDEFINED , "path/file.feature:3 # Scenario: scenario_name" );
219
+ counter .addScenario (Status .UNDEFINED , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
213
220
counter .addStep (Status .PENDING );
214
- counter .addScenario (Status .PENDING , "path/file.feature:3 # Scenario: scenario_name" );
221
+ counter .addScenario (Status .PENDING , createTestCase ( "path/file.feature" , 3 , " Scenario: scenario_name") );
215
222
counter .printStats (new PrintStream (baos ));
216
223
217
224
assertThat (baos .toString (), startsWith (String .format ("" +
@@ -230,4 +237,53 @@ void should_print_failed_ambiguous_pending_undefined_scenarios_if_strict() {
230
237
"4 Scenarios" )));
231
238
}
232
239
240
+ private static TestCase createTestCase (String uri , int line , String name ) {
241
+ return new TestCase () {
242
+ @ Override
243
+ public Integer getLine () {
244
+ return getLocation ().getLine ();
245
+ }
246
+
247
+ @ Override
248
+ public Location getLocation () {
249
+ return new Location (line , -1 );
250
+ }
251
+
252
+ @ Override
253
+ public String getKeyword () {
254
+ return "Scenario" ;
255
+ }
256
+
257
+ @ Override
258
+ public String getName () {
259
+ return name ;
260
+ }
261
+
262
+ @ Override
263
+ public String getScenarioDesignation () {
264
+ return null ;
265
+ }
266
+
267
+ @ Override
268
+ public List <String > getTags () {
269
+ return Collections .emptyList ();
270
+ }
271
+
272
+ @ Override
273
+ public List <TestStep > getTestSteps () {
274
+ return Collections .emptyList ();
275
+ }
276
+
277
+ @ Override
278
+ public URI getUri () {
279
+ return URI .create (uri );
280
+ }
281
+
282
+ @ Override
283
+ public UUID getId () {
284
+ return UUID .randomUUID ();
285
+ }
286
+ };
287
+ }
288
+
233
289
}
0 commit comments