@@ -77,13 +77,10 @@ func (s *suite) matchStep(step *messages.PickleStep) *models.StepDefinition {
77
77
}
78
78
79
79
func (s * suite ) runStep (ctx context.Context , pickle * Scenario , step * Step , scenarioErr error , isFirst , isLast bool ) (rctx context.Context , err error ) {
80
- var (
81
- match * models.StepDefinition
82
- sr = models .NewStepResult (pickle .Id , step .Id , match )
83
- )
80
+ var match * models.StepDefinition
84
81
85
82
rctx = ctx
86
- sr . Status = StepUndefined
83
+ status : = StepUndefined
87
84
88
85
// user multistep definitions may panic
89
86
defer func () {
@@ -105,19 +102,19 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
105
102
106
103
switch {
107
104
case errors .Is (err , ErrPending ):
108
- sr . Status = StepPending
105
+ status = StepPending
109
106
case errors .Is (err , ErrSkip ), err == nil && scenarioErr != nil :
110
- sr . Status = StepSkipped
107
+ status = StepSkipped
111
108
case errors .Is (err , ErrUndefined ):
112
- sr . Status = StepUndefined
109
+ status = StepUndefined
113
110
case err != nil :
114
- sr . Status = StepFailed
111
+ status = StepFailed
115
112
case err == nil && scenarioErr == nil :
116
- sr . Status = StepPassed
113
+ status = StepPassed
117
114
}
118
115
119
116
// Run after step handlers.
120
- rctx , err = s .runAfterStepHooks (ctx , step , sr . Status , err )
117
+ rctx , err = s .runAfterStepHooks (ctx , step , status , err )
121
118
122
119
shouldFail := s .shouldFail (err )
123
120
@@ -132,25 +129,20 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
132
129
133
130
switch {
134
131
case err == nil :
135
- sr . Status = models .Passed
132
+ sr : = models .NewStepResult ( models . Passed , pickle . Id , step . Id , match , nil )
136
133
s .storage .MustInsertPickleStepResult (sr )
137
-
138
134
s .fmt .Passed (pickle , step , match .GetInternalStepDefinition ())
139
135
case errors .Is (err , ErrPending ):
140
- sr . Status = models .Pending
136
+ sr : = models .NewStepResult ( models . Pending , pickle . Id , step . Id , match , nil )
141
137
s .storage .MustInsertPickleStepResult (sr )
142
-
143
138
s .fmt .Pending (pickle , step , match .GetInternalStepDefinition ())
144
139
case errors .Is (err , ErrSkip ):
145
- sr . Status = models .Skipped
140
+ sr : = models .NewStepResult ( models . Skipped , pickle . Id , step . Id , match , nil )
146
141
s .storage .MustInsertPickleStepResult (sr )
147
-
148
142
s .fmt .Skipped (pickle , step , match .GetInternalStepDefinition ())
149
143
default :
150
- sr .Status = models .Failed
151
- sr .Err = err
144
+ sr := models .NewStepResult (models .Failed , pickle .Id , step .Id , match , err )
152
145
s .storage .MustInsertPickleStepResult (sr )
153
-
154
146
s .fmt .Failed (pickle , step , match .GetInternalStepDefinition (), err )
155
147
}
156
148
}()
@@ -165,14 +157,11 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
165
157
166
158
match = s .matchStep (step )
167
159
s .storage .MustInsertStepDefintionMatch (step .AstNodeIds [0 ], match )
168
- sr .Def = match
169
160
s .fmt .Defined (pickle , step , match .GetInternalStepDefinition ())
170
161
171
162
if err != nil {
172
- sr = models .NewStepResult (pickle .Id , step .Id , match )
173
- sr .Status = models .Failed
163
+ sr := models .NewStepResult (models .Failed , pickle .Id , step .Id , match , nil )
174
164
s .storage .MustInsertPickleStepResult (sr )
175
-
176
165
return ctx , err
177
166
}
178
167
@@ -191,20 +180,17 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, scena
191
180
Nested : match .Nested ,
192
181
Undefined : undef ,
193
182
}
194
- sr .Def = match
195
183
}
196
184
197
- sr = models .NewStepResult (pickle .Id , step .Id , match )
198
- sr .Status = models .Undefined
185
+ sr := models .NewStepResult (models .Undefined , pickle .Id , step .Id , match , nil )
199
186
s .storage .MustInsertPickleStepResult (sr )
200
187
201
188
s .fmt .Undefined (pickle , step , match .GetInternalStepDefinition ())
202
189
return ctx , ErrUndefined
203
190
}
204
191
205
192
if scenarioErr != nil {
206
- sr = models .NewStepResult (pickle .Id , step .Id , match )
207
- sr .Status = models .Skipped
193
+ sr := models .NewStepResult (models .Skipped , pickle .Id , step .Id , match , nil )
208
194
s .storage .MustInsertPickleStepResult (sr )
209
195
210
196
s .fmt .Skipped (pickle , step , match .GetInternalStepDefinition ())
0 commit comments