0

使用 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

...

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

4

1 回答 1

2

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

And /^I (?:drag|have added) an "image component" to my page$/ do
  # code
end
于 2013-01-30T20:53:36.013 回答