Description
I have a before-Step hook to replace variables in steps. You can use it do things like this:
Scenario: Demonstrate variables
Given I set "name" to "Zaphod"
I login as ${name}
Normally variables are set by other steps, and they provide a convenient way to pass some context around between API calls. One use case is to test an API where I need to create a parent and a child object. I can do that using variables like so:
Scenario: Test creation of books
Given I create an author named "Jane Doe"
When I create a book "Intro to godog" for author ${author_id}
Then the API returned succeeded
Doing this many times becomes tedious, especially when you need to go down more levels. To solve that I want to leverage a multistep:
ctx.Step("there exists an author with a book", func(context.Context) godog.Steps {
return godog.Steps{
`I create an author named "Jane Doe"`,
`I create a book "Intro to godog" for author ${author_id}`,
"the API returned succeeded",
}
}
so I can just start my tests like this:
Scenario: Test creation of books
Given there exists an author with a book
...
This is failing, because my StepContext.Before
is never invoked for steps returned by a multistep.
📦 Which tool/library version are you using?
godog v0.12.4
Metadata
Metadata
Assignees
Labels
No labels