我有一个Cucumber步骤,看起来像这样:
When I enter the credentials for the user
还有另一个说
When I enter the correct credentials for the user
对应的步骤定义如下:
@When("I enter the ([^\"]*) for the user$")
public void stepDefinition(String cred){
//code
}
@When("I enter the correct ([^\"]*) for the user$")
public void otherStepDefinition(String cred){
//other code
}
但是我的第二个黄瓜步骤(“我为用户输入正确的凭据”)与第一个步骤定义匹配,只是在凭据中添加了“正确”的单词。
- 我该怎么办?
- 我对正则表达式不熟悉。是否可能从'When'步骤中排除“正确”部分,以便我可以拥有一个基本步骤,可以使用“正确”部分进行扩展?
@When("I enter the (\\S*) for the user$")
作为第一条规则。 - Wiktor Stribiżew