Skip to content
New issue

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

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow suite-level configuration of steps and hooks #453

Merged
merged 6 commits into from
Jan 12, 2022
Merged

Conversation

vearutop
Copy link
Member

@vearutop vearutop commented Jan 12, 2022

Description

During discussion it turned out step/hooks instrumentation happens for every scenario.

Motivation & context

Setting up steps/hooks for each scenario may be unnecessary overhead in most cases, as step/hooks handlers are usually identical for every scenario. Improvement idea is to create "global" setup in suite initializer and use it as a base for each scenario.

So that you could use

TestSuiteInitializer: func(suiteContext *godog.TestSuiteContext) {
	local.RegisterSteps(suiteContext.ScenarioContext())
},

instead of or additionally to

ScenarioInitializer: func(s *godog.ScenarioContext) {
	local.RegisterSteps(s)
},

Also, to simplify debugging, this PR runs scenario in the same goroutine when concurrency is disabled. This allows preserving original stack.

Type of change

  • New feature (non-breaking change which adds new behaviour)

Note to other contributors

No note.

Update required of cucumber.io/docs

No update.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

@codecov
Copy link

codecov bot commented Jan 12, 2022

Codecov Report

Merging #453 (ee85501) into main (a6fef3f) will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #453      +/-   ##
==========================================
+ Coverage   81.31%   81.47%   +0.15%     
==========================================
  Files          27       27              
  Lines        2178     2186       +8     
==========================================
+ Hits         1771     1781      +10     
+ Misses        313      312       -1     
+ Partials       94       93       -1     
Impacted Files Coverage Δ
run.go 76.47% <100.00%> (+2.32%) ⬆️
test_context.go 77.19% <100.00%> (+0.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6fef3f...ee85501. Read the comment docs.

@vearutop vearutop requested a review from nhatthm January 12, 2022 22:04
@vearutop vearutop marked this pull request as ready for review January 12, 2022 22:04
@vearutop vearutop merged commit 9baac0f into main Jan 12, 2022
@vearutop vearutop deleted the suite-level-hooks branch January 12, 2022 22:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants