Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run BeforeStep for multisteps #491

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Run BeforeStep for multisteps #491

wants to merge 1 commit into from

Conversation

wichert
Copy link
Contributor

@wichert wichert commented Aug 5, 2022

This PR will try to fix #486. Currently still work-in-progress.

馃搵 Checklist:

  • 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.

@wichert wichert self-assigned this Aug 5, 2022
@wichert
Copy link
Contributor Author

wichert commented Aug 5, 2022

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)
 		}
 	}

This demonstrates the bug reported in #486
@github-actions
Copy link

Go API Changes

# github.com/cucumber/godog
## compatible changes
Feature: added

# summary
Inferred base version: v0.12.5
Suggested version: v0.13.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Before-Step hook not invoked for multisteps
1 participant