Search code examples
cucumberbddcucumber-jvmgherkincucumber-java

How to make "the" optional in my cucumber BDD Step Definitions?


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) {
    ...
}

Solution

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