【发布时间】:2019-12-15 00:20:18
【问题描述】:
在为 BDD 定义 Gherkin 格式的验收标准时,是否有首选方法?
我是否应该将场景拆分如下...
Scenario: User saves contact details
Given I am on the contact details page
When I enter the following details
| email | phone |
| pete@gmail.com | 012345678 |
And I save the details
Then the details are correctly saved
Scenario: User saves contact details with a very long email address
Given I am on the contact details page
When I enter the following details
| email | phone |
| peterpeterperterlongemailaddress1234567890@gmailsomething.com | 012345678 |
And I save the details
Then the details are correctly saved
Scenario: User saves contact details with a very long phone number
etc
还是应该使用具有多个轮廓的单个场景?
Scenario: User saves contact details
Given I am on the contact details page
When I enter the following details
| email | phone |
| <email> | <phone> |
And I save the details
Then the details are correctly saved
Examples:
| email | phone |
| pete@gmail.com | 012345678 |
| peterpeterperterlongemailaddress1234567890@gmailsomething.com | 012345678 |
| pete@gmail.com | 012345678901234567890 |
后者可能更容易适应/添加,但对我来说失去了场景的基本概念。
更新 我刚刚看到以下文章,其中讨论了这一点。建议后者是更好的方法。 https://www.hindsightsoftware.com/blog/scenario-outlines
它建议如下:
Scenario: User saves contact details
Given I am on the contact details page
When I enter the following details
| email | phone |
| <email> | <phone> |
And I save the details
Then the details are correctly saved
Examples:
| scenario | email | phone |
| basic details saved | pete@gmail.com | 012345678 |
| very long email address | peterpeterperterlongemailaddress1234567890@gmailsomething.com | 012345678 |
| very long phone number | pete@gmail.com | 012345678901234567890 |
【问题讨论】:
标签: cucumber bdd specflow gherkin