如何管理黄瓜-jvm的过去和现在时态

时间:2013-01-30 11:59:05

标签: cucumber bdd cucumber-jvm

使用cucumber-jvm(或任何其他BDD工具),如何管理过去和现在文本的使用?

例如:

Given that I have logged in as "admin"
And I have navigated to the "editor" page
When I drag an "image component" to my page
Then I see it appear

这很好,但随后在其他功能中,这成为一个先驱:

Background: 
  Given that I have logged in as "admin"
  And I am editing a page
  And I have added an "image component" to my page

...

所以这些动作实际上是相同的,但是使用了两组域语言。如何管理这个?

1 个答案:

答案 0 :(得分:2)

假设操作相同,您可以在步骤中使用非捕获组:

And /^I (?:drag|have added) an "image component" to my page$/ do
  # code
end