0
votes

I have a step in Cucumber/Java feature like this:

Then execution should fail with the response message "At most 20 characters > are allowed."

Underneath that I have:

@When("executin should fail with the response message \"([^\\"]*)\"")

The problem is that I want to use it in many scenarios where the number of characters is changing. Once it's 20 but another time it's 100 or 200.

I've tried something like:

Then execution should fail with the response message "At most (20|100|200) > characters are allowed."

but it doesn't work.

Can anyone plese help how to handle it? Thanks

1
You can pass only values via scenario and hard code the "At most > characters are allowed." "^execution should fail with the response message At most ( "([^"]*)" > characters are allowed.$" - Vinee-the-Pooh

1 Answers

0
votes

You had the wrong term for your original step definition.

Steps beginning with "Then" should have step definitions that begin with "Then". Yours began with "When".

Try this:

Step:

Then execution should fail with the response message "At most 20 characters > are allowed."

Step definition:

@Then("execution should fail with the response message \"([^\\\"]*)\"")

You also misspelled "execution" in your first variation of the step definition, and you needed one more backslash to escape the double quote in side the parenthesis.