Skip to content

proposal: Code generation for test steps #72

Description

@bkielbasa

Describe the solution you'd like
We discussed in #65 that we want some kind of way of writing less test code.
My idea is to add markers to functions which define the step definition. The first words should be GoBDD step: and after that, there should be a regular expression. Example:

// +gobdd-step: I add (\d+) and (\d+)
func add(ctx context.Context, var1, var2 int) error {
...
}

After calling command gobdd configure generate the command will output a new function definition.

func ConfigureSteps(suite *gobdd.Suite) {
    suite.AddStep(add, `I add (\d+) and (\d+)`)
    // other steps will go here
}

It will be copy&paste ready peace of code. If you provide the -f output.go parameter, the command will parse the output.go code:

  • if there's no ConfigureSteps func, it will add it as the very last function in the file
  • if it exists - it will replace its body.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions