3

I'd like to match either of the following BDD:

Then the response status should be "200"
Then response status should be "200"

I want to make "the" optional. I want these two rules to map to the SAME step.

Here is my attempt, but it doesn't work:

@Then("^(?:the | )response status should be \"([^\"]*)\"$")
public void the_response_status_should_be(String arg1) {
    ...
}
Katie
  • 45,622
  • 19
  • 93
  • 125

2 Answers2

4

This might work ... "^(?:the )*response status should be \"([^\"]*)\"$"

Katie
  • 45,622
  • 19
  • 93
  • 125
jgauld
  • 639
  • 5
  • 10
2

Using Cucumber Expression this can be done quite easily just by surrounding the optional text with parentheses like this:

(the )response status should be "200"

Read more...

Saikat
  • 14,222
  • 20
  • 104
  • 125