Open vec715 opened 3 months ago
Hi, your approach is possible, but I think it will come with many limitations:
*.feature
files are the place we will define the feature, scenario, steps, rules,... in Gherkin style, which is easily to read and understand by all members of a team (dev, QA, PM, stakeholders...). So with your approach, all the step definitions and implementations will be written in the same .go
file or even if you separate them into callback functions, they will still be coupled with each others, and will prevent members other than the person who code it, can understand the feature thoroughly.context.WithValue
and each step can retrieve the variable from context or from the struct fields. Otherwise, the example of Godog readme is enough to give us ideas to address this need.Even thought it is possible and also already be implemented in Goconvey, I think Godog should not follow the same, as we're using BDD, it leverages the collaboration of the whole team, the step definitions of .feature
file plays a crucial role as well as it help us have a clear view on what the behavior should look like, we can break it down to smaller parts with ease and we don't need to worry about how underlying code is implemented.
I agree, godog
is all about running gherkin
files given step definitions. Replacing gherkin
with go
code moves it into a different problem space.
🤔 What's the problem you're trying to solve?
The current flat design of Godog tests makes the structure difficult to read and navigate. Unlike Goconvey, Godog doesn't natively support nested steps, which would improve readability and allow for easier reuse of variables from parent functions. This limitation makes writing and maintaining tests more challenging and time-consuming
✨ What's your proposed solution?
Implement a feature in Godog that allows for nested steps, similar to Goconvey's approach. This would involve:
As an initial attempt, I created a custom ScenarioBuilder struct to simulate nested steps:
This approach initially worked
But (!) I encountered issues when more test cases were added.
⛏ Have you considered any alternatives or workarounds?
No response
đź“š Any additional context?
No response