File tree 4 files changed +41
-66
lines changed
main/java/cucumber/runtime/formatter
resources/cucumber/runtime/formatter
4 files changed +41
-66
lines changed Original file line number Diff line number Diff line change
1
+ package cucumber .runtime .formatter ;
2
+
3
+ import gherkin .formatter .JSONFormatter ;
4
+ import gherkin .formatter .model .Examples ;
5
+ import gherkin .formatter .model .Scenario ;
6
+ import gherkin .formatter .model .ScenarioOutline ;
7
+ import gherkin .formatter .model .Step ;
8
+
9
+ public class CucumberJSONFormatter extends JSONFormatter {
10
+ private boolean inScenarioOutline = false ;
11
+
12
+ public CucumberJSONFormatter (Appendable out ) {
13
+ super (out );
14
+ }
15
+
16
+ @ Override
17
+ public void scenarioOutline (ScenarioOutline scenarioOutline ) {
18
+ inScenarioOutline = true ;
19
+ }
20
+
21
+ @ Override
22
+ public void examples (Examples examples ) {
23
+ // NoOp
24
+ }
25
+
26
+ @ Override
27
+ public void startOfScenarioLifeCycle (Scenario scenario ) {
28
+ inScenarioOutline = false ;
29
+ super .startOfScenarioLifeCycle (scenario );
30
+ }
31
+
32
+ @ Override
33
+ public void step (Step step ) {
34
+ if (!inScenarioOutline ) {
35
+ super .step (step );
36
+ }
37
+ }
38
+ }
Original file line number Diff line number Diff line change 4
4
import cucumber .runtime .io .URLOutputStream ;
5
5
import cucumber .runtime .io .UTF8OutputStreamWriter ;
6
6
import gherkin .formatter .Formatter ;
7
- import gherkin .formatter .JSONFormatter ;
8
7
9
8
import java .io .File ;
10
9
import java .io .IOException ;
@@ -46,7 +45,7 @@ public class FormatterFactory {
46
45
put ("html" , HTMLFormatter .class );
47
46
put ("pretty" , CucumberPrettyFormatter .class );
48
47
put ("progress" , ProgressFormatter .class );
49
- put ("json" , JSONFormatter .class );
48
+ put ("json" , CucumberJSONFormatter .class );
50
49
put ("usage" , UsageFormatter .class );
51
50
put ("rerun" , RerunFormatter .class );
52
51
}};
Original file line number Diff line number Diff line change 2
2
3
3
import cucumber .api .PendingException ;
4
4
import cucumber .api .Scenario ;
5
+ import cucumber .runtime .formatter .CucumberJSONFormatter ;
5
6
import cucumber .runtime .io .ClasspathResourceLoader ;
6
7
import cucumber .runtime .io .Resource ;
7
8
import cucumber .runtime .io .ResourceLoader ;
@@ -51,7 +52,7 @@ public void runs_feature_with_json_formatter() throws Exception {
51
52
" Scenario: scenario name\n " +
52
53
" When s\n " );
53
54
StringBuilder out = new StringBuilder ();
54
- JSONFormatter jsonFormatter = new JSONFormatter (out );
55
+ JSONFormatter jsonFormatter = new CucumberJSONFormatter (out );
55
56
List <Backend > backends = asList (mock (Backend .class ));
56
57
ClassLoader classLoader = Thread .currentThread ().getContextClassLoader ();
57
58
RuntimeOptions runtimeOptions = new RuntimeOptions ("" );
Original file line number Diff line number Diff line change 97
97
],
98
98
"type" : " scenario"
99
99
},
100
- {
101
- "id" : " feature-3;scenariooutline-1" ,
102
- "description" : " " ,
103
- "name" : " ScenarioOutline_1" ,
104
- "keyword" : " Scenario Outline" ,
105
- "line" : 14 ,
106
- "steps" : [
107
- {
108
- "name" : " so_1 \u003c a\u003e " ,
109
- "keyword" : " Given " ,
110
- "line" : 15
111
- },
112
- {
113
- "name" : " so_2 \u003c c\u003e cucumbers" ,
114
- "keyword" : " When " ,
115
- "line" : 16
116
- },
117
- {
118
- "name" : " \u003c b\u003e so_3" ,
119
- "keyword" : " Then " ,
120
- "line" : 17
121
- }
122
- ],
123
- "examples" : [
124
- {
125
- "id" : " feature-3;scenariooutline-1;" ,
126
- "description" : " " ,
127
- "name" : " " ,
128
- "keyword" : " Examples" ,
129
- "line" : 19 ,
130
- "rows" : [
131
- {
132
- "id" : " feature-3;scenariooutline-1;;1" ,
133
- "cells" : [
134
- " a" ,
135
- " b" ,
136
- " c"
137
- ],
138
- "line" : 20
139
- },
140
- {
141
- "id" : " feature-3;scenariooutline-1;;2" ,
142
- "cells" : [
143
- " 12" ,
144
- " 5" ,
145
- " 7"
146
- ],
147
- "line" : 21
148
- },
149
- {
150
- "id" : " feature-3;scenariooutline-1;;3" ,
151
- "cells" : [
152
- " 20" ,
153
- " 5" ,
154
- " 15"
155
- ],
156
- "line" : 22
157
- }
158
- ]
159
- }
160
- ],
161
- "type" : " scenario_outline"
162
- },
163
100
{
164
101
"description" : " " ,
165
102
"name" : " " ,
You can’t perform that action at this time.
0 commit comments