Last active
June 20, 2016 16:52
-
-
Save fdiasr/242c43608c4612dc4bf8995229252d9e to your computer and use it in GitHub Desktop.
Bdd Scenarios Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://knpuniversity.com/screencast/rest/testing#play | |
| # api/features/programmer.feature | |
| # ... | |
| Scenario: Create a programmer | |
| Given I have the payload: | |
| """ | |
| { | |
| "nickname": "ObjectOrienter", | |
| "avatarNumber" : "2", | |
| "tagLine": "I'm from a test!" | |
| } | |
| """ | |
| When I request "POST /api/programmers" | |
| Then the response status code should be 201 | |
| And the "Location" header should be "/api/programmers/ObjectOrienter" | |
| And the "nickname" property should equal "ObjectOrienter" | |
| # ... | |
| Background: | |
| Given the user "weaverryan" exists | |
| # ... | |
| Scenario: GET one programmer | |
| Given the following programmers exist: | |
| | nickname | avatarNumber | | |
| | UnitTester | 3 | | |
| When I request "GET /api/programmers/UnitTester" | |
| Then the response status code should be 200 | |
| And the following properties should exist: | |
| """ | |
| nickname | |
| avatarNumber | |
| powerLevel | |
| tagLine | |
| """ | |
| And the "nickname" property should equal "UnitTester" | |
| Scenario: GET a collection of programmers | |
| Given the following programmers exist: | |
| | nickname | avatarNumber | | |
| | UnitTester | 3 | | |
| | CowboyCoder | 5 | | |
| When I request "GET /api/programmers" | |
| Then the response status code should be 200 | |
| And the "programmers" property should be an array | |
| And the "programmers" property should contain 2 items | |
| Scenario: Validation errors | |
| Given I have the payload: | |
| """ | |
| { | |
| "avatarNumber" : "2", | |
| "tagLine": "I'm from a test!" | |
| } | |
| """ | |
| When I request "POST /api/programmers" | |
| Then the response status code should be 400 | |
| And the following properties should exist: | |
| """ | |
| type | |
| title | |
| errors | |
| """ | |
| And the "errors.nickname" property should exist | |
| But the "errors.avatarNumber" property should not exist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment