如何在我的黄瓜BDD步骤定义中选择“the”?

时间:2016-10-28 19:31:33

标签: cucumber bdd cucumber-jvm gherkin cucumber-java

我想匹配以下任一BDD:

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

我想制作“可选”。我希望这两个规则映射到SAME步骤。

这是我的尝试,但不起作用:

@Then("^(?:the | )response status should be \"([^\"]*)\"$")
public void the_response_status_should_be(String arg1) {
    ...
}

2 个答案:

答案 0 :(得分:2)

使用黄瓜表达可以很容易地做到这一点,只需将可选文本用括号括起来即可:

(the )response status should be "200"

Read more...

答案 1 :(得分:1)

这可能有用...... "^(?:the )*response status should be \"([^\"]*)\"$"

相关问题