我正在寻找一些背景信息,这些信息可以说明功能和场景之间的区别。
说,我有一个文件use_administration.feature
Feature: Use administration area
So that I can administrate the application
As an administrator
I can visit the administration area
Scenario: Get a login form
Given I am not logged in
When I visit the administration dashboard
Then I should see a login-form
Scenario: Access the Dashboard
Given I am not logged in
And there is a user "admin@example.com" with password "password"
When I log in with username "admin@example.com" and password "password"
Then I should see a dashboard
我认为这些场景非常明确。
但是,当查看另一个Feature
时,问题会变得更加清晰
Feature: Manage campings
So that a writer can manage her campings
As a logged in writer
I want to update and delete campings
Scenario: Logged in writer can create a new camping
Given I am administrator
And no campings on the campings listing
When I create a Camping named "Beautifull Green"
And I visit the "Campings" administration page
Then I should see a camping "Beautifull Green"
Scenario: Logged in writer sees own campings dashboard
Given I am administrator
And I have a camping "Beautifull Green"
When I visit the administration dashboard
Then I should see a panel titled "My Campings"
Then I should see camping "Beautifull Green"
Scenario: Logged in writer can update campings
Given I am administrator
And I have a camping "Beautifull Green"
When I visit the update page for "Beautifull Green"
And I update the name to "updated!"
And I visit the "Campings" administration page
Then I should see a camping "updated!"
Scenario: Logged in writer can update camping from dashboard
Given I am administrator
And I have a camping "Beautifull Green"
When I visit the administration dashboard
Then I should see the "edit"-link for "Beautifull Green"
很多这些场景都是重叠的,因此应该是自己的功能。请注意,重叠主要由共享步骤覆盖。但仍然有很多重复。
我的主要问题是:何时是某个功能,何时是一个场景。任何经验法则? 是否应该包含多少场景特征的良好实践?或者我完全误解了整个主题?
答案 0 :(得分:1)
在我看来,这完全是关于现实生活中的组织技能。如果你能用简单的英语清楚地描述场景,那就足够了。
让我们检查你的第二个功能。有很多问题。
用户角色是什么?作家还是管理员?您在一个功能中提到了它们。这是不可接受的。
描述格式存在问题。这不对英语。它应该是:
In order to keep my campaigns up to date
As a logged in writer
I want to manage my campaigns
或
As a logged in writer
I want to manage my campaigns
So that I can keep my campaigns up to date
这里有一些注意事项
在场景中有“鉴于我是管理员”和“我有一个露营'美丽绿色'”的重叠。那是不必要的。您应该使用Background
来描述它。例如:
Background:
Given I have logged in as an Administrator
And I have a camping "Beautifull Green"
这些将为您节省所有重复。如果你想测试Create
,只需使用其他名称,相同的“Nice Red”。
情景标题太长。不需要主题。您之前已经描述过用户和背景。标题可以是:
Scenario: Create new campaign
# description here
Scenario: Update campaign
# .....
希望这些帮助。