You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the solution you'd like
We discussed in #65 that we want some kind of way of writing less test code.
My idea is to add markers to functions which define the step definition. The first words should be GoBDD step: and after that, there should be a regular expression. Example:
// +gobdd-step: I add (\d+) and (\d+)funcadd(ctx context.Context, var1, var2int) error {
...
}
After calling command gobdd configure generate the command will output a new function definition.
funcConfigureSteps(suite*gobdd.Suite) {
suite.AddStep(add, `I add (\d+) and (\d+)`)
// other steps will go here
}
It will be copy&paste ready peace of code. If you provide the -f output.go parameter, the command will parse the output.go code:
if there's no ConfigureSteps func, it will add it as the very last function in the file
if it exists - it will replace its body.
The text was updated successfully, but these errors were encountered:
I like this and I would certainly use this in our team. Would it be clearer if the comment is in a form of a marker and starts with the + sign to differentiate it from normal comments? For example:
// +gobdd-step: I add (\d+) and (\d+)
Would there be also a viable option not to have the ConfigureSteps at all? I've looked deeply at how the https://magefile.org/ works - it's using both build tags and markers and auto-generates a temporary go file (could this in our case contain the ConfigureSteps?), which it then runs, and after the run it removes the temporary file. There's a flag not to delete the generated file, for debugging purposes etc.
Thanks for your comment. I updated the description with the marker.
About skipping the ConfigureSteps function. As I mentioned earlier, I'm not a huge fan of a lot of magic. And what's more, to do it we'll probably have to have an external binary which will generate and remove the file. That's what godog does and this is one of main reasons why this lib was created.
But, if you find an idea of improving it - please create the proposal :)
Describe the solution you'd like
We discussed in #65 that we want some kind of way of writing less test code.
My idea is to add markers to functions which define the step definition. The first words should be
GoBDD step:
and after that, there should be a regular expression. Example:After calling command
gobdd configure generate
the command will output a new function definition.It will be copy&paste ready peace of code. If you provide the
-f output.go
parameter, the command will parse theoutput.go
code:ConfigureSteps
func, it will add it as the very last function in the fileThe text was updated successfully, but these errors were encountered: