【发布时间】:2018-09-04 21:43:59
【问题描述】:
如何忽略黄瓜中相同值的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 会报错。
如果您需要任何进一步的信息或者我遗漏了什么,请告诉我。
【问题讨论】:
-
在正则表达式中使用非捕获组 - (?:.*?) 到任何组。方法中只需要一个参数。
-
谢谢@Grasshopper - 你总是帮助我们......我一定会试试这个并很快回复你.. 另外你能分享任何链接,我可以从哪里获得关于正则表达式的所有这些信息黄瓜
-
是的 Grasshopper,它运行良好..您可以将其添加为答案...请在答案中也分享链接..这将有很大帮助:)
标签: cucumber cucumber-jvm cucumberjs cucumber-java cucumber-junit