user12051965
user12051965

Reputation: 147

Alternative parameter type in Cucumber

I have the following Cucumber step and I want to test it for 1st, 2nd, 3rd ... etc item.

When user makes a request for the 1st item

An here is its implementation

@When("user makes a request for the {int}st/nd/rd/th item")

Seems like its correct but the test does not run and I get error Parameter types cannot be alternative: ... What is wrong?

Upvotes: 1

Views: 850

Answers (1)

M.P. Korstanje
M.P. Korstanje

Reputation: 12039

Alternatives are separated by whitespace so the parameter binds strongly into the alternative. So it is expecting {int}st or nd or rd or th.

You will have to use regular expression. E.g:

^user makes a request for the (\d+)(?:st|nd|rd|th) item$

Upvotes: 3

Related Questions