Releases: go-bdd/gobdd
Releases · go-bdd/gobdd
Changing the step func definiton
The main change is related to #34.
Now, every step function should accept the Context as the first parameter and returns an only error. It is explained in more details in the docs https://go-bdd.github.io/doc/creating-steps.html.
Adding predefined steps in testhttp package
Here's the full list:
_ = addStep.AddStep(`^I make a (GET|POST|PUT|DELETE|OPTIONS) request to "([^"]*)"$`, testHTTP.makeRequest)
_ = addStep.AddStep(`^the response code equals (\d+)$`, testHTTP.statusCodeEquals)
_ = addStep.AddStep(`^the response contains a valid JSON$`, testHTTP.validJSON)
_ = addStep.AddStep(`^the response is "(.*)"$`, testHTTP.theResponseIs)
_ = addStep.AddStep(`^the response header "(.*)" equals "(.*)"$`, testHTTP.responseHeaderEquals)
_ = addStep.AddStep(`^I have a (GET|POST|PUT|DELETE|OPTIONS) request "(.*)"$`, testHTTP.iHaveARequest)
_ = addStep.AddStep(`^I set request header "(.*)" to "(.*)"$`, testHTTP.iSetRequestSetTo)
_ = addStep.AddStep(`^I set request body to "([^"]*)"$`, testHTTP.iSetRequestBodyTo)
_ = addStep.AddStep(`^the request has body "(.*)"$`, testHTTP.theRequestHasBody)
_ = addStep.AddStep(`^I make the request$`, testHTTP.iMakeRequest)
What's more, I made RequestKey
and ResponseKey
so defining your custom steps should be easier.
Adding default values
In this release, we added a default value to Get*
functions in the context
.
// will fail when the param is not defined
requiredParam := ctx.GetInt(something{})
def := 123
// will never panic
optionalParam := ctx.GetInt(something{}, def)