如何忽略黄瓜中步长定义变量声明的相同值?
所以假设我有如下例子:
Scenario Outline: Looking up the definition of fruits
Given the user is on the Wikionary home page
When the user <name> looks up the definition of the word <name>
Then they should see the definition 'An edible fruit produced by the pear tree, similar to an apple but elongated towards the stem.'
Examples:
| name |
| pear |
步骤定义如下:
@When("^the user (.*?) looks up the definition of the word (.*?)$")
public void when(String name, String name2){
System.out.println(name);
System.out.println(name2);
}
现在在上面的步骤中,我创建了两个不必要的变量,我这样做是因为我的黄瓜报告应该在when语句的两个位置获取名称。 如果我只放一个变量,那么黄瓜会抛出一个错误。
如果您需要任何进一步的信息或我遗失任何信息,请通知我。
在正则表达式中使用非捕获组 - (?:.*?)
到任何组。方法中只需要一个参数。
https://agileforall.com/just-enough-regular-expressions-for-cucumber/