BDD and Gherkin is very useful for realising what software is meant to do.
Those business friendly user stories also are very good to use for modelling the domain of system.
A while ago I was happy to learn that you can do it in golang too.
There is this awesome tool called godog, which was build by @l3pp4rd this summer.
It uses cucumber’s gherkin parser gherkin-go.
It adds a simple runner on top of it, which fits neatly into story TDD cycle.
So if the output of your example workshop is feature like
You can easily inforporate it into your development with godog.
First you’ll have to install it with
Then, assuming your feature file is at features/three-for-two-sale.feature you can generate boilerplate code by just running godog from parent directory.
It will detect thefeature files and will output something similar to
You can just copy-paste generated code to your test file discount_test.go and with next run godog will suggest you what to implement
To pass the step you have to make it return null, to fail - return error.
If you need to pass state in between your steps, then you can create a Context struct, store state there and assign all the steps to it.
Being very young, godog is not without quirks or issues, but is very usable and saves loads of time if you are used to develop in this kind of way.