我正在寻找一些背景信息来阐明功能和场景之间的区别。
说,我有一个文件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"
这些场景中有很多重叠,因此可能应该是功能本身。请注意,重叠部分主要由共享步骤覆盖。然而仍然有很多重复。
我的主要问题是:什么时候是功能,什么时候是场景。有什么经验法则吗?是否有关于一个功能应该包含多少个场景的良好做法?还是我完全误解了整个话题?