如何忽略黄瓜中相同值的stepdefinition变量声明
How to ignore stepdefinition variable declaration in cucumber for same value
如何忽略 cucmber 中相同值的 stepdefination 变量声明?
所以假设我有如下示例:
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 语句中的两个位置获取名称。
如果我只放置一个变量,那么 Cucumber 会抛出一个错误。
如果您需要任何进一步的信息或者我遗漏了什么,请告诉我。
在正则表达式中使用非捕获组 - (?:.*?)
到任何组。方法中只需要一个参数。
https://agileforall.com/just-enough-regular-expressions-for-cucumber/
如何忽略 cucmber 中相同值的 stepdefination 变量声明?
所以假设我有如下示例:
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 语句中的两个位置获取名称。
如果我只放置一个变量,那么 Cucumber 会抛出一个错误。
如果您需要任何进一步的信息或者我遗漏了什么,请告诉我。
在正则表达式中使用非捕获组 - (?:.*?)
到任何组。方法中只需要一个参数。
https://agileforall.com/just-enough-regular-expressions-for-cucumber/