我遇到的情况是我的测试套件中的每个方案大纲都使用相同的参数集(我使用的是javascript):
Feature: Select a Product
Install Checklist for Product
Scenario Outline: functionA() is called on page type <type> -- No errors
Given I load the site and go to a <type> page
Then I should see no errors are thrown
Examples:
| type |
| "product" |
| "home" |
| "collection" |
Scenario Outline: functionA() is called on page type <type> -- Minimal delay
Given I load the site and go to a <type> page
Then there is a minimal delay before calling functionA()
Examples:
| type |
| "product" |
| "home" |
| "collection" |
Scenario Outline: functionA() is called -- correct type <type>
Given I load the site and go to a <type> page
Then the page type is <type>
Examples:
| type |
| "product" |
| "home" |
| "collection" |
...many more tests using an identical Examples array
我正在寻求改进此代码的结构,而我看到的最好的方法是将Examples
部分放在单个Scenario Outlines
之外,作为全局参数。 。本质上,我希望使用Scenarios
中的每个条目来运行每个Examples
,而不必为每个Examples
重复Scenario
数组。我敢肯定,您会发现修改Examples
数组将来会很麻烦。
在黄瓜中可以做到这一点吗?
类似的东西:
Feature Outline: Select a Product
Install Checklist for Product
Scenario Outline: functionA() is called on page type <type> -- No errors
Given I load the site and go to a <type> page
Then I should see no errors are thrown
Scenario Outline: functionA() is called on page type <type> -- Minimal delay
Given I load the site and go to a <type> page
Then there is a minimal delay before calling functionA()
Scenario Outline: functionA() is called -- correct type <type>
Given I load the site and go to a <type> page
Then the page type is <type>
...many more tests using an identical Examples array
Examples:
| type |
| "product" |
| "home" |
| "collection" |
或
Feature: Select a Product
Install Checklist for Product
Rule Outline: verify functionA() on page type <type>
Scenario Outline: functionA() is called on page type <type> -- No errors
Given I load the site and go to a <type> page
Then I should see no errors are thrown
Scenario Outline: functionA() is called on page type <type> -- Minimal delay
Given I load the site and go to a <type> page
Then there is a minimal delay before calling functionA()
Scenario Outline: functionA() is called -- correct type <type>
Given I load the site and go to a <type> page
Then the page type is <type>
...many more tests using an identical Examples array
Examples:
| type |
| "product" |
| "home" |
| "collection" |
编辑:对于以后有兴趣的人,我在这里打开了一个相关的问题:https://github.com/cucumber/cucumber/issues/879