I am looking for some background information that shines light on the difference between a feature and a scenario.
Say, I have a file 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
I would consider these Scenario's pretty well-defined.
However, when looking at another Feature
, the problem gets clearer
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"
A lot of these scenario's overlap, and as such should probably have been Features's on their own. Note that the overlap is covered with shared steps mostly. Yet still there is a lot of repetition.
My main question is: when is something a feature, when is it a scenario. Any rules of thumb? Are there good practices as to how many Scenario's a Feature should contain? Or am I completely misunderstanding this whole topic?
In my opinion this is all about organization skill in real life. If you can describe scenarios clearly in plain English, that's enough.
Let's check your second feature. There are many problems.
What is the user role? Writer or Administrator? You mentioned both of them in one feature. That's unacceptable.
There is problem in description format. It's not right English. It should be:
In order to keep my campaigns up to date
As a logged in writer
I want to manage my campaigns
or
As a logged in writer
I want to manage my campaigns
So that I can keep my campaigns up to date
Some notes here
There is overlap of "Given I am administrator" and "And I have a camping 'Beautifull Green'" in Scenarios. That's unnecessary. You should use Background
to describe that. For example:
Background:
Given I have logged in as an Administrator
And I have a camping "Beautifull Green"
These will save you all of the duplicate. If you want to test Create
, just use another name instead, same "Nice Red".
The Scenarios titles are too long. No need subject. You've already described the user and background before. The titles can be:
Scenario: Create new campaign
# description here
Scenario: Update campaign
# .....
Hope these help.