Skip to content

Instantly share code, notes, and snippets.

@tejovanthn
Created August 24, 2016 08:34
Show Gist options
  • Save tejovanthn/69b357cefecae7ae6cc63432b6945ba4 to your computer and use it in GitHub Desktop.
Save tejovanthn/69b357cefecae7ae6cc63432b6945ba4 to your computer and use it in GitHub Desktop.
Behave feature tests
Feature: API User
Background: User setups
Given a user with name "userA"
And a user with name "userB"
Scenario Outline: A user and an admin tries to access /user routes
Given <name> has role <role>
When <method> of "/users" is accessed by userA
Then status <code> is returned
Examples: /users route
| name | role | method | code |
| userA | user | GET | 403 |
| userA | user | POST | 200 |
| userA | user | PUT | 405 |
| userA | user | DELETE | 405 |
| userA | admin | GET | 200 |
| userA | admin | POST | 200 |
| userA | admin | PUT | 405 |
| userA | admin | DELETE | 405 |
Feature: Basic User
Scenario: Create a user
Given a user with email "test@test.com"
Then user has email "test@test.com"
Scenario: Edit a user
Given a user with email "test@test.com"
When user edits email to "best@test.com"
Then user has email "best@test.com"
Scenario: Delete a user
Given a user with email "test@test.com"
When user is deleted
Then there is no user with email "test@test.com"
Scenario: Archive a user
Given a user with email "test@test.com"
When user is archived
Then there is no user with email "test@test.com"
But there is a user with email "test@test.com" if archive is True
Scenario: Find a user
Given 5 users
And a user with email "test@test.com"
When user with email "test@test.com" is searched for
Then user with email "test@test.com" is returned
Scenario: No user
Given 5 users
When user with email "test@test.com" is searched for
Then there is no user with email "test@test.com"
Scenario: Get a user
Given a user with email "test@test.com"
When user is accessed by id
Then user.email is "test@test.com"
Scenario: Two users with the same name
Given user with email "test1@test.com" and name "Test User"
And user with email "test2@test.com" and name "Test User"
Then user 1 has username "test-user"
And user 2 has username "test-user-1"
Feature: testing google
Scenario: visit google and check
When we visit google
Then it should have a title "Google"
Scenario: visit google and check
When we visit google
Then it should have a title "Eventosaur"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment