godog
godog copied to clipboard
Run BeforeStep for multisteps
This PR will try to fix #486. Currently still work-in-progress.
📋 Checklist:
- [x] I agree to respect and uphold the Cucumber Community Code of Conduct
- [ ] I've changed the behaviour of the code
- [ ] I have added/updated tests to cover my changes.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] Users should know about my change
- [ ] I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.
Note to self: this trivial fix does not seem to work, the tests never finish with this change.
diff --git a/suite.go b/suite.go
index 261ed28..04026a7 100644
--- a/suite.go
+++ b/suite.go
@@ -180,7 +180,8 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, prevS
return ctx, nil
}
- ctx, err = s.maybeSubSteps(match.Run(ctx))
+ r1, r2 := match.Run(ctx)
+ ctx, err = s.maybeSubSteps(r1, r2, pickle)
return ctx, err
}
@@ -332,7 +333,7 @@ func (s *suite) maybeUndefined(ctx context.Context, text string, arg interface{}
return ctx, undefined, nil
}
-func (s *suite) maybeSubSteps(ctx context.Context, result interface{}) (context.Context, error) {
+func (s *suite) maybeSubSteps(ctx context.Context, result interface{}, pickle *Scenario) (context.Context, error) {
if nil == result {
return ctx, nil
}
@@ -349,9 +350,7 @@ func (s *suite) maybeSubSteps(ctx context.Context, result interface{}) (context.
var err error
for _, text := range steps {
- if def := s.matchStepText(text); def == nil {
- return ctx, ErrUndefined
- } else if ctx, err = s.maybeSubSteps(def.Run(ctx)); err != nil {
+ if ctx, err = s.runStep(ctx, pickle, &Step{Text: text}, nil, false, false); err != nil {
return ctx, fmt.Errorf("%s: %+v", text, err)
}
}
Go API Changes
# github.com/cucumber/godog ## compatible changes Feature: added # summary Inferred base version: v0.12.5 Suggested version: v0.13.0