捕获场景中的条件
Capturing conditions in scenarios
如果有条件成功的场景我可以写成Given, And, And... Then button is enabled.
,但是我怎么写If either x,y, or z aren't set, the button remains disabled
的负面场景。
下面是一个积极场景的例子:
Scenario: Enable the Add to Favorites button
When the consumer is viewing an item
And the consumer selects an item
And the consumer selects a size
And the consumer selects a quantity
Then the Add to Favorites button becomes enabled
可以(或应该)在一种情况下完成吗?由于所有成功的“按钮启用”方案都需要这 3 个元素,我可以将它们添加到 Before()
挂钩吗?
感谢您的时间和关注。
我会这样做:
Scenario: Do not enable the Add to Favorites button without a selected item
When the consumer is viewing an item
And the consumer selects a size
And the consumer selects a quantity
Then the Add to Favorites button does not become enabled
Scenario: Do not enable the Add to Favorites button without a selected size
When the consumer is viewing an item
And the consumer selects an item
And the consumer selects a quantity
Then the Add to Favorites button does not become enabled
Scenario: Do not enable the Add to Favorites button without a selected quantity
When the consumer is viewing an item
And the consumer selects an item
And the consumer selects a size
Then the Add to Favorites button does not become enabled
作为情景大纲的做法最好是测试多输入多输出。所以考虑同样的场景如下:
Scenario Outline: Verify the "Add to Favorites" button state
When the consumer is viewing an item
And the item is "<itemCondition>"
And the item size is "<sizeCondition>"
And the item quantity is "<quantityCondition>"
Then the "Add to Favorites" button becomes "<buttonState>"
Examples: Conditions
| itemCondition | sizeCondition | quantityCondition | buttonState|
| Selected | Selected | Selected | enabled |
| Not Selected | Not Selected | Not Selected | disabled |
| Selected | Not Selected | Not Selected | disabled |
| Selected | Selected | Not Selected | disabled |
全部好评!感谢您的输入。以下是我使用的表格:
Feature: Add item to Favorites List
As a consumer (guest or member) who is shopping on the App, I'd like the ability to favorite items that I maybe interested in.
Rule: Any consumer, guest or member, can favorite an item after selecting pre-requisites (size/quantity/shipping)
Scenario: Favorite an item - member
Given I have logged in
And I have searched the product inventory
When I choose a desired item with specified pre-requisites
Then the app should allow me to add it to my member favorites list
Scenario: Favorite an item - guest
Given I have not logged in
And I have searched the product inventory
When I choose a desired item with specified pre-requisites
Then the app should allow me to add it to my guest favorites list
如果有条件成功的场景我可以写成Given, And, And... Then button is enabled.
,但是我怎么写If either x,y, or z aren't set, the button remains disabled
的负面场景。
下面是一个积极场景的例子:
Scenario: Enable the Add to Favorites button
When the consumer is viewing an item
And the consumer selects an item
And the consumer selects a size
And the consumer selects a quantity
Then the Add to Favorites button becomes enabled
可以(或应该)在一种情况下完成吗?由于所有成功的“按钮启用”方案都需要这 3 个元素,我可以将它们添加到 Before()
挂钩吗?
感谢您的时间和关注。
我会这样做:
Scenario: Do not enable the Add to Favorites button without a selected item
When the consumer is viewing an item
And the consumer selects a size
And the consumer selects a quantity
Then the Add to Favorites button does not become enabled
Scenario: Do not enable the Add to Favorites button without a selected size
When the consumer is viewing an item
And the consumer selects an item
And the consumer selects a quantity
Then the Add to Favorites button does not become enabled
Scenario: Do not enable the Add to Favorites button without a selected quantity
When the consumer is viewing an item
And the consumer selects an item
And the consumer selects a size
Then the Add to Favorites button does not become enabled
作为情景大纲的做法最好是测试多输入多输出。所以考虑同样的场景如下:
Scenario Outline: Verify the "Add to Favorites" button state
When the consumer is viewing an item
And the item is "<itemCondition>"
And the item size is "<sizeCondition>"
And the item quantity is "<quantityCondition>"
Then the "Add to Favorites" button becomes "<buttonState>"
Examples: Conditions
| itemCondition | sizeCondition | quantityCondition | buttonState|
| Selected | Selected | Selected | enabled |
| Not Selected | Not Selected | Not Selected | disabled |
| Selected | Not Selected | Not Selected | disabled |
| Selected | Selected | Not Selected | disabled |
全部好评!感谢您的输入。以下是我使用的表格:
Feature: Add item to Favorites List
As a consumer (guest or member) who is shopping on the App, I'd like the ability to favorite items that I maybe interested in.
Rule: Any consumer, guest or member, can favorite an item after selecting pre-requisites (size/quantity/shipping)
Scenario: Favorite an item - member
Given I have logged in
And I have searched the product inventory
When I choose a desired item with specified pre-requisites
Then the app should allow me to add it to my member favorites list
Scenario: Favorite an item - guest
Given I have not logged in
And I have searched the product inventory
When I choose a desired item with specified pre-requisites
Then the app should allow me to add it to my guest favorites list