有什么方法可以在黄瓜步骤定义中指定例如(汽车)? [英] Is there any way to specify eg (car|cars) in a cucumber step definition?
问题描述
所以我有2种情况。...一个开始
So I have 2 scenarios....one starts out
Given I have 1 car
另一个开始
Given I have 2 cars
我希望它们使用相同的步骤定义-即类似
I'd like them to use the same step definition - ie something like this
Given('I have {int} (car|cars)',
我知道可以指定2个可能的值(例如,一个或多个汽车),但是我不知道该如何做。
I know it's possible to do specify 2 possible values (ie car or cars), but I can't for the life of me remember how. Does anyone know? I'm using typescript, protractor, angular, selenium.
也尝试过
Given(/^I have {int} (car|cars)$
推荐答案
在cukeExp中,()成为可选字符。这就是您想要的。
Within cukeExp, the () become optional characters. That is what you want.
所以您的表达式应该是
Given('I have {int} car(s)')
乐于助人-在此处可以找到更多信息:
Happy to help - More information can be found here: https://cucumber.io/docs/cucumber/cucumber-expressions/ - Switch to JS code at the top.
Luke-黄瓜贡献者。
Luke - Cucumber contributor.
这篇关于有什么方法可以在黄瓜步骤定义中指定例如(汽车)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!