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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function .After() is called before fuction StepContext().After() #434

Closed
leonbergr opened this issue Oct 6, 2021 · 5 comments · Fixed by #444
Closed

Function .After() is called before fuction StepContext().After() #434

leonbergr opened this issue Oct 6, 2021 · 5 comments · Fixed by #444

Comments

@leonbergr
Copy link

What version of godog are you using?

> Godog version is: v0.12.1

What version of Go are you using?

> go version go1.17 linux/amd64

What did you do?

I have this setup (pseudo code):

s.After(func(){ fmt.Println("After scenario") })
s.Stepcontext().After(func() { fmt.Println("After step") })

What did you expect to see?

...
After step
After step
After step
After scenario

What did you see instead?

...
After step
After step
After scenario
After step

Additional context

It is probably caused by this:

godog/suite.go

Lines 108 to 110 in 239a424

if (err == nil && isLast) || err != nil {
rctx, err = s.runAfterScenarioHooks(rctx, pickle, err)
}

@vearutop
Copy link
Member

vearutop commented Oct 7, 2021

Interesting, thank you for raising this issue, I'll check what's happening.

@leonbergr
Copy link
Author

Thank you, please let me know if you need additional info.

@alexrudd
Copy link

Also just hit this same issue 😄

@vearutop
Copy link
Member

vearutop commented Dec 1, 2021

@leonbergr @alexrudd could you check if #444 (branch after-order) behaves within your expectations?

You may use branched version with

go install github.com/cucumber/godog/cmd/godog@after-order

or

go get -u github.com/cucumber/godog@after-order

depending if you use godog as CLI or as a library.

@leonbergr
Copy link
Author

I just checked with the master now. It looks ok, thank you!

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 a pull request may close this issue.

3 participants