I'm new to cucumber and currently stuck trying to organize/structure some features/scenarios. The behavior I'm trying to capture is that of users, guests and admins using my website. The website is basically for creating private and public todo lists.
And these are the specific scenarios I want to test:
- Registered users can view their private todo lists (but not someone else's private todo list)
- Guests (anonymous users) can only view public todo lists
- Admins can view all lists
- Managing todo lists
Right now I'm going with something like this:
Feature: Managing Todo lists
In order to be more productive
As a user of the site
I want to be able to manage todo lists
Background:
Given a user named "[email protected]" with password "secret-one"
Given a user named "[email protected]" with password "secret-two"
Given an admin named "[email protected]" with password "admin"
Scenario: [email protected] can view his own private todo lists
Scenario: [email protected] can not view [email protected] private todo lists
Scenario: [email protected] can view [email protected] and [email protected] private todo lists
Scenario: [email protected] can create private todo lists
Scenario: [email protected] can delete todo lists they own
Scenario: [email protected] can delete user-one@email todo list
Scenario: guests can view all public todo lists
The problem I'm running into is the setup for each scenario. For example, in the first scenario I have to assume [email protected]
is logged in. In the first [email protected]
scenario I have to assume the admin is logged in. In the last scenario I need to assume no one is logged in.
So how do I manage those Given
s? Do I just add a
Given [email protected] is logged in
To every single scenario? Or is there a better way to go about structuring all this? Please help! I'm sure this is a very common pattern that cucumber users need to test.