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 "user-one@email.com" with password "secret-one"
Given a user named "user-two@email.com" with password "secret-two"
Given an admin named "admin@email.com" with password "admin"
Scenario: user-one@email.com can view his own private todo lists
Scenario: user-one@email.com can not view user-two@email.com private todo lists
Scenario: admin@email.com can view user-one@email.com and user-two@email.com private todo lists
Scenario: user-one@email.com can create private todo lists
Scenario: user-one@email.com can delete todo lists they own
Scenario: admin@email.com 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 user-one@email.com
is logged in. In the first admin@email.com
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 user-one@email.com 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.