-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have step expressions and implementations closer to each other #398
Comments
You can also init steps as func InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^I eat (\d+)$`, func(arg1 int) error {
return godog.ErrPending
})
ctx.Step(`^there are (\d+) godogs$`, func(arg1 int) error {
return godog.ErrPending
})
ctx.Step(`^there should be (\d+) remaining$`, func(arg1 int) error {
return godog.ErrPending
})
} having expressions and implementations next to each other. But I'm not sure I follow the suggestion or the idea of the issue. |
@vearutop , I had initially started doing just that and learned that if the implementations are long, that becomes unwieldy (not to mention it not lending itself well to sharing scenario context). I was hoping there'd be a way to do it similarly to using annotations in Java:
|
Maybe it would help to arrange lengthy step definitions as functions that operate on func InitializeScenario(ctx *godog.ScenarioContext) {
longStep1(ctx)
longStep2(ctx)
ctx.Step(`^there should be (\d+) remaining$`, func(arg1 int) error {
return godog.ErrPending
})
}
func longStep1(ctx *godog.ScenarioContext) {
ctx.Step(`^I eat (\d+)$`, func(arg1 int) error {
// Long body follows...
return godog.ErrPending
})
}
func longStep2(ctx *godog.ScenarioContext) {
ctx.Step(`^there are (\d+) godogs$`, func(arg1 int) error {
// Long body follows...
return godog.ErrPending
})
} They can also be grouped together to simplify func longSteps(ctx *godog.ScenarioContext) {
longStep1(ctx)
longStep2(ctx)
} |
Sorry, I was unclear. By scenario context, I had meant context specific to the scenarios being tested, not Regardless, what you have above looks fruitful. Thanks! |
As I was trying that out, I realized there's still a bunch of jumping around in the code since |
In the next version 0.12.0 we will have context support. 409 |
you can do step binding (IDE level not saying test_main) in vscode. use cucumber full support plugin and in setting.json file add these
|
Just an addition to @waytocypress comment, for the one who are not used to vscode:
{
"cucumberautocomplete.steps": [
"**/*.go"
],
"cucumberautocomplete.syncfeatures": "**/*.features"
} Note: the configuration is detailed in the extensions descriptions. I confirm it works great. Thanks |
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
When step expressions and implementations are separated I feel annoyed because I would like efficiency.
Describe the solution you'd like
A clear and concise description of what you want to happen.
Java has annotations (ie
@Given
,@When
,@Then
) which allows the expression to be right next to the implementation.In, go, the following can be done:
Additional context
Add any other context or screenshots about the feature request here.
If the above were done, the suggested implementation upon missing steps would need to be changed as well.
The text was updated successfully, but these errors were encountered: