Open
Description
👓 What did you see?
In my test setup, I have a main FeatureContext that registers scenarios and a nested AbcFeatureContext that also registers its own scenarios and hooks.
func FeatureContext(ctx context.Context, s *godog.ScenarioContext, log logger.Logger) {
// Main steps and hooks
AbcFeatureContext(ctx, s)
}
func AbcFeatureContext(ctx context.Context, s *godog.ScenarioContext) {
s.Before(func(ctx context.Context, _ *godog.Scenario) (context.Context, error) {
// Pre-checks specific to AbcFeatureContext
return ctx, nil
})
// Steps specific to AbcFeatureContext
s.After(func(ctx context.Context, _ *godog.Scenario, _ error) (context.Context, error) {
// Cleanup specific to AbcFeatureContext
return ctx, nil
})
}
I have noticed that the Before and After hooks defined in AbcFeatureContext are being executed for all scenarios registered in FeatureContext, not just for those specific to AbcFeatureContext.
✅ What did you expect to see?
I expected the hooks in AbcFeatureContext to apply only to scenarios that are meant to be part of AbcFeatureContext and not to every scenario registered under FeatureContext.
📦 Which tool/library version are you using?
go 1.23.0
godog v0.14.1
🔬 How could we reproduce it?
No response
📚 Any additional context?
Also let me know if this is expected behaviour and you have any workaround for it?
Metadata
Metadata
Assignees
Labels
No labels