假设我正在使用 Cucumber 开发购物车 BDD。购物车相当复杂并且有很多花里胡哨的东西,但这对于“博客”或“用户资料”可能同样适用。
我一直认为“购物车”是Feature,而花里胡哨的是Scenario。但是,这可能会生成大型Feature文件,并且与Scenario的字面意思相违背。这是看起来的样子:
Feature: Cart
So that I can buy items
As a user
I want to place items in a cart
#.... Many more scenarios
Scenario: Empty a filled cart
Given 2 products in my cart
When I visit the cart page
And I press "Empty cart"
Then I should see the text:
"""
Your cart is empty.
"""
Scenario: Empty an empty cart
Given 0 products in my cart
When I visit the cart page
Then I should not see the "Empty cart" button
# Many more Scenario's
填写的细节越多,这个“空车”组就会变得越长。我想知道,“清空购物车”是否应该被视为独立功能?这将导致许多Features,都包含但几个Scenario的。然后场景变得更像“上下文”。像这样:
Feature: Emptying Cart
So that I can reconsider my shopping-spree
As a user
I want to empty my cart
Scenario: with a filled cart
Given 2 products in my cart
When I visit the cart page
And I press "Empty cart"
Then I should see the text:
"""
Your cart is empty.
"""
Scenario: with an empty cart
Given 0 products in my cart
When I visit the cart page
Then I should not see the "Empty cart" button
什么是使某物成为Feature的好指南?我什么时候应该将Scenario重新组合到他们自己的Feature中?一个功能通常有多少个场景?