go-bdd / gobdd

BDD framework
https://go-bdd.github.io/gobdd/
MIT License
115 stars 20 forks source link

Do not require returning the context from a step #98

Closed sagikazarmark closed 4 years ago

sagikazarmark commented 4 years ago

Is your feature request related to a problem? Please describe. Returning the context seems unnecessary (since it's internal state is mutated) and it clutters the code.

Describe the solution you'd like Accept the context in the step function parameter list, but don't require returning it.

Describe alternatives you've considered This would make sense if the context was immutable, but it's not.

Additional context Based on our conversation on slack with @bkielbasa I felt like there is a misunderstanding:

the context is the holder of the state. It has to be kept somewhere so to avoid global variables I decided to do this way. Do you have any better idea?

Accepting the context as a parameter is OK, having to return it as well seems unnecessary.

bkielbasa commented 4 years ago

I can explain my intention. I wanted to give the possibility to run every step case in parallel. Treat the context as the holder of the state between steps. Keeping it as it is would give the possibility. I was thinking about the context as an immutable value object. Maybe it's time to change it.

I'm going to change it to a pointer and hide behind the interface you proposed. Then returning the context won't be necessary.

sagikazarmark commented 4 years ago

You don't actually have to make it a pointer, because the map behind the context is a reference type. But if you introduce an interface, it won't matter.

Introducing an interface on the other hand might be a backward incompatible change.