From 7d984effb38feabbee185d9a5cda1e6afabb99b5 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Tue, 24 Aug 2021 23:02:41 +0200 Subject: [PATCH] Run before step hooks before matching (#425) * Run before step hooks before matching * Add note to CHANGELOG.md Co-authored-by: nhatthm --- CHANGELOG.md | 10 +++++++++- suite.go | 6 +++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d485f6..4c7df3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt --- +## [Unreleased] + +### Fixed + +- Unintended change of behavior in before step hook ([424](https://github.com/cucumber/godog/pull/424) - [nhatthm]) + ## [v0.12.0] ### Added @@ -190,7 +196,8 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt -[unreleased]: https://github.com/cucumber/godog/compare/v0.11.0...main +[unreleased]: https://github.com/cucumber/godog/compare/v0.12.0...main +[v0.12.0]: https://github.com/cucumber/godog/compare/v0.11.0...v0.12.0 [v0.11.0]: https://github.com/cucumber/godog/compare/v0.10.0...v0.11.0 [v0.10.0]: https://github.com/cucumber/godog/compare/v0.9.0...v0.10.0 [0.9.0]: https://github.com/cucumber/godog/compare/v0.8.1...v0.9.0 @@ -215,3 +222,4 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt [chirino]: https://github.com/chirino [radtriste]: https://github.com/radtriste [karfrank]: https://github.com/karfrank +[nhatthm]: https://github.com/nhatthm diff --git a/suite.go b/suite.go index 1b8fca2..fc77cab 100644 --- a/suite.go +++ b/suite.go @@ -134,13 +134,13 @@ func (s *suite) runStep(ctx context.Context, pickle *Scenario, step *Step, prevS ctx, err = s.runBeforeScenarioHooks(ctx, pickle) } + // run before step handlers + ctx, err = s.runBeforeStepHooks(ctx, step, err) + match = s.matchStep(step) s.storage.MustInsertStepDefintionMatch(step.AstNodeIds[0], match) s.fmt.Defined(pickle, step, match.GetInternalStepDefinition()) - // run before step handlers - ctx, err = s.runBeforeStepHooks(ctx, step, err) - if err != nil { sr = models.NewStepResult(pickle.Id, step.Id, match) sr.Status = models.Failed