在 Gherkin 中使用正确的语法

Cha*_*ann 2 syntax cucumber gherkin

查找有关 Gherkin 的文档似乎非常困难,所以我想知道是否有办法增加步骤定义以使测试人员能够使用正确的语法。显示我的意思的一个例子是:

...Testing...
Then I see there is 1 item
...More testing...
Then I see there are 2 items
Run Code Online (Sandbox Code Playgroud)

显然,这两个步骤将使用相同的代码。我定义了一个几乎可以工作的步骤定义:

Then(/^I see there (is|are) (\d+) item(s)?$/) do |item_count|
  ...code...
end
Run Code Online (Sandbox Code Playgroud)

除了问题是它将is/are可选的复数解释s为参数。有什么方法可以向小黄瓜发出信号,这些只是为了允许正确的语法?

Gra*_*per 8

使用 ?: 在组的开头将其标记为非捕获,Cucumber 不会将其作为参数传递。

/^I see there (?:is|are) (\d+) item(?:s)?$/
Run Code Online (Sandbox Code Playgroud)