1

I am not sure it this is intended to be so, but I am confused by the behavior.

When I have the following Scenario Outline:

Scenario Outline: outline1
Given url
And query parameters <query_params>
When method
Then status is
Examples:
| method | endpoint   | query_params | status |
| GET    | /endpoint1 | ?a=1&b=1     | 200    |
| GET    | /endpoint1 | ?a=1&b=1&c=3 | 200    |

I see the following snippet generated.

func FeatureContext(s *godog.Suite) {
s.Step(^method GET$, methodGET)
s.Step(^query parameters \?a=(\d+)&b=(\d+)$, queryParametersAB)
s.Step(^query parameters \?a=(\d+)&b=(\d+)&c=(\d+)$, queryParametersABC)
}

As you can see 2 lines of "query parameters" produces 2 different functions. Why is godog parsing this text? This is a little different from cucumber gherkin parsing.

One side effect of this is that if I have 100 lines in the data table, I am forced to implement all of them.

Is there a way I can ask godog to not do this parsing?

iam thadiyan
  • 471
  • 1
  • 4
  • 19

1 Answers1

0

The solution to the problem is to use double quotes around as given below.

Scenario Outline: outline1
Given url
And query parameters "<query_params>"
When method
Then status is
Examples:
| method | endpoint   | query_params | status |
| GET    | /endpoint1 | ?a=1&b=1     | 200    |
| GET    | /endpoint1 | ?a=1&b=1&c=3 | 200    |

Then the following will be generated:

s.Step(`^query parameters "([^"]*)"$`, queryParameters)
iam thadiyan
  • 471
  • 1
  • 4
  • 19