Skip to content

Have step expressions and implementations closer to each other #398

@noel-yap

Description

@noel-yap

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:

var steps := map[string]interface{}{
    `^I eat (\d+)$`: func(arg1 int) error {
      return godog.ErrPending
    },
    `^there are (\d+) godogs$`: func(arg1 int) error {
      return godog.ErrPending
    },
    `^there should be (\d+) remaining$`: func(arg1 int) error {
      return godog.ErrPending
    },
}

func InitializeScenario(ctx *godog.ScenarioContext) {
	for expr, fn := range steps {
		ctx.Step(expr, fn)
	}
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions