@@ -4,7 +4,7 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
4
4
var Cucumber = require ( '../../cucumber' ) ;
5
5
6
6
var world ;
7
- var allFeaturesSucceeded = true ;
7
+ var featuresResult = Cucumber . Runtime . FeaturesResult ( options . strict ) ;
8
8
var emptyHook = Cucumber . SupportCode . Hook ( function ( callback ) { callback ( ) ; } , { } ) ;
9
9
var beforeSteps = Cucumber . Type . Collection ( ) ;
10
10
var afterSteps = Cucumber . Type . Collection ( ) ;
@@ -20,8 +20,7 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
20
20
self . visitFeatures ( features , function ( ) {
21
21
if ( walkDomain . exit )
22
22
walkDomain . exit ( ) ;
23
- var featuresResult = self . didAllFeaturesSucceed ( ) ;
24
- callback ( featuresResult ) ;
23
+ callback ( featuresResult . isSuccessful ( ) ) ;
25
24
} ) ;
26
25
} ,
27
26
@@ -36,7 +35,7 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
36
35
} ,
37
36
38
37
visitFeature : function visitFeature ( feature , callback ) {
39
- if ( ! allFeaturesSucceeded && options . failFast ) {
38
+ if ( ! featuresResult . isSuccessful ( ) && options . failFast ) {
40
39
return callback ( ) ;
41
40
}
42
41
var payload = { feature : feature } ;
@@ -55,7 +54,7 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
55
54
} ,
56
55
57
56
visitScenario : function visitScenario ( scenario , callback ) {
58
- if ( ! allFeaturesSucceeded && options . failFast ) {
57
+ if ( ! featuresResult . isSuccessful ( ) && options . failFast ) {
59
58
return callback ( ) ;
60
59
}
61
60
supportCodeLibrary . instantiateNewWorld ( function ( world ) {
@@ -140,10 +139,7 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
140
139
141
140
visitStepResult : function visitStepResult ( stepResult , callback ) {
142
141
scenarioResult . witnessStepResult ( stepResult ) ;
143
- var status = stepResult . getStatus ( ) ;
144
- if ( status === Cucumber . Status . FAILED || ( options . strict && ( status === Cucumber . Status . PENDING ) ) ) {
145
- allFeaturesSucceeded = false ;
146
- }
142
+ featuresResult . witnessStepResult ( stepResult ) ;
147
143
var payload = { stepResult : stepResult } ;
148
144
var event = AstTreeWalker . Event ( AstTreeWalker . STEP_RESULT_EVENT_NAME , payload ) ;
149
145
self . broadcastEvent ( event , callback ) ;
@@ -212,10 +208,6 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
212
208
return ! supportCodeLibrary . isStepDefinitionNameDefined ( stepName ) ;
213
209
} ,
214
210
215
- didAllFeaturesSucceed : function didAllFeaturesSucceed ( ) {
216
- return allFeaturesSucceeded ;
217
- } ,
218
-
219
211
getScenarioStatus : function getScenarioStatus ( ) {
220
212
return scenarioResult . getStatus ( ) ;
221
213
} ,
@@ -240,34 +232,13 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
240
232
attachments . clear ( ) ;
241
233
} ,
242
234
243
- witnessUndefinedStep : function witnessUndefinedStep ( ) {
244
- if ( options . strict ) {
245
- allFeaturesSucceeded = false ;
246
- }
247
- scenarioResult . witnessStepStatus ( Cucumber . Status . UNDEFINED ) ;
248
- } ,
249
-
250
- witnessSkippedStep : function witnessSkippedStep ( ) {
251
- scenarioResult . witnessStepStatus ( Cucumber . Status . SKIPPED ) ;
252
- } ,
253
-
254
235
witnessNewScenario : function witnessNewScenario ( scenario ) {
255
236
apiScenario = Cucumber . Api . Scenario ( self , scenario ) ;
256
237
scenarioResult = Cucumber . Runtime . ScenarioResult ( ) ;
257
238
beforeSteps . clear ( ) ;
258
239
afterSteps . clear ( ) ;
259
240
} ,
260
241
261
- processDryRunStep : function processDryRunStep ( step , callback ) {
262
- if ( options . strict && self . isStepUndefined ( step ) ) {
263
- self . witnessUndefinedStep ( ) ;
264
- self . skipUndefinedStep ( step , callback ) ;
265
- } else {
266
- self . witnessSkippedStep ( ) ;
267
- self . skipStep ( step , callback ) ;
268
- }
269
- } ,
270
-
271
242
getScenario : function getScenario ( ) {
272
243
return apiScenario ;
273
244
} ,
@@ -281,12 +252,9 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
281
252
} ,
282
253
283
254
processStep : function processStep ( step , callback ) {
284
- if ( options . dryRun ) {
285
- self . processDryRunStep ( step , callback ) ;
286
- } else if ( self . isStepUndefined ( step ) ) {
287
- self . witnessUndefinedStep ( ) ;
255
+ if ( self . isStepUndefined ( step ) ) {
288
256
self . skipUndefinedStep ( step , callback ) ;
289
- } else if ( self . isSkippingSteps ( ) ) {
257
+ } else if ( options . dryRun || self . isSkippingSteps ( ) ) {
290
258
self . skipStep ( step , callback ) ;
291
259
} else {
292
260
self . executeStep ( step , callback ) ;
@@ -299,16 +267,12 @@ function AstTreeWalker(features, supportCodeLibrary, listeners, options) {
299
267
300
268
skipStep : function skipStep ( step , callback ) {
301
269
var skippedStepResult = Cucumber . Runtime . StepResult ( { step : step , status : Cucumber . Status . SKIPPED } ) ;
302
- var payload = { stepResult : skippedStepResult } ;
303
- var event = AstTreeWalker . Event ( AstTreeWalker . STEP_RESULT_EVENT_NAME , payload ) ;
304
- self . broadcastEvent ( event , callback ) ;
270
+ self . visitStepResult ( skippedStepResult , callback ) ;
305
271
} ,
306
272
307
273
skipUndefinedStep : function skipUndefinedStep ( step , callback ) {
308
274
var undefinedStepResult = Cucumber . Runtime . StepResult ( { step : step , status : Cucumber . Status . UNDEFINED } ) ;
309
- var payload = { stepResult : undefinedStepResult } ;
310
- var event = AstTreeWalker . Event ( AstTreeWalker . STEP_RESULT_EVENT_NAME , payload ) ;
311
- self . broadcastEvent ( event , callback ) ;
275
+ self . visitStepResult ( undefinedStepResult , callback ) ;
312
276
}
313
277
} ;
314
278
return self ;
0 commit comments