-
Notifications
You must be signed in to change notification settings - Fork 255
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
docs: add duplicate steps example and "Motivation" README #642
base: main
Are you sure you want to change the base?
Conversation
_examples/dupsteps/dupsteps_test.go
Outdated
Name: t.Name(), | ||
ScenarioInitializer: func(context *godog.ScenarioContext) { | ||
// NOTE: loading implementations of steps for different scenarios here | ||
(&cloggedDrain{}).addCloggedDrainSteps(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "clogged drain" scenario (above) works fine until the "flat tire" scenario (below) is added (e.g., in a subsequent commit).
The "I fixed it" step from the newly added flatTire
scenario silently overrides the matching step in the previously defined step from the cloggedDrain
scenario. The writer of the clogged drain scenario will have to investigate why his/her scenario suddenly stops working.
We'd like the tool to support a distributed development workflow where developers can work on scenarios independently, without having to take into account (and reuse) all pre-existing, matching steps.
_examples/dupsteps/dupsteps_test.go
Outdated
|
||
func (ft *flatTire) addFlatTireSteps(ctx *godog.ScenarioContext) { | ||
ctx.Step(`^I ran over a nail and got a flat tire$`, ft.gotFlatTire) | ||
ctx.Step(`^I fixed it$`, ft.iFixedIt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: the text of this new (or the old, pre-existing) step could be something less obviously matching - e.g., ^(.+)\s+fixed\s+(.+)$
, making it harder for the second developer to spot and re-use the step instead of writing their own.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #642 +/- ##
==========================================
- Coverage 83.21% 80.27% -2.94%
==========================================
Files 28 40 +12
Lines 3413 3148 -265
==========================================
- Hits 2840 2527 -313
- Misses 458 502 +44
- Partials 115 119 +4 ☔ View full report in Codecov by Sentry. |
The text from the first para ... "Running the tests for the two Scenarios separately (e.g., using a separate .... seems contradict the proposed solution |
} | ||
} | ||
|
||
func collectGoSteps(goFilePath string, steps map[string]*StepMatch) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont know if this static parser will spot the cases where the ScenarioContext has been wrapped.
I've seen (and I use) a scheme where folk register steps via a proxy wrapper of the ScenarioContext, that adds generic behaviours to the steps being registered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! 👍
If you provide an example, I'll work up a test case to fix.
Do you have a fix strategy in mind?
Hmm, okay I guess that didn't come out so clearly then. What I'm trying to say is that by testing Scenarios individually (aka separately), we can work around the problem of ambiguity; but, that causes the problem (for us) of producing a single report covering all Scenarios, given that Suggestions welcome for a clearer wording to express this! |
🤔 What's changed?
_examples
to describe & illustrate the "problem" we're facing;⚡️ What's your motivation?
The motivation and a more detailed description of the example case is described in the accompanying README file.
🏷️ What kind of change is this?
Just an example, which may be of use or inspiration to others facing a similar situation.
♻️ Anything particular you want feedback on?
Yes, everything written above and in the included
README
file.📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.