Monday, March 13, 2023

Two different flavours of feature files

Format 1 - Scenario outline with example table

Given I have a valid auth token
When I submit a POST request to create a user with the following details:
| first_name | last_name | email | mobile_phone | date_of_birth | password | username |
| <first_name>| <last_name> | <email> | <mobile_phone>| <date_of_birth> | <password> | <username> |
Then the response status code should be <status_code>

Examples:
| first_name | last_name| email | mobile_phone | date_of_birth | password | username | status_code |
| John | Doe | johndoe@example.com | 1234567890 | 1990-01-01 | password123 | johndoe123 | 201 |
| Jane | Smith | janesmith@example.com | 0987654321 | 1985-02-14 | password456 | janesmith12 | 201 |

This format gives a higher level of abstraction where the same scenario is run multiple times with different sets of data. Yes data including the expected result as well. 

This format is useful when you don't want to repeat the same scenario. Also when you have a simpler payload.


Format 2 - Single Scenario with Given\When\Then steps

Feature: Create User API

Scenario: Create User Successfully
Given the user payload is:
| first_name | John             |
| last_name | Doe             |
| email | john.doe@example.com |
| mobile_phone | 1234567890         |
| date_of_birth | 1990-01-01           |
| password | password             |
| username | johndoe              |
When I send a {method} request to {path}
Then the response status code should be 201
|method  | path | status_code |
| POST |/users/create"|201 |

This gives more detailed description of the scenario. Each @Given, @When, @Then step is elaborated with relevant data.

In this case you may be having more specific scenarios and conditions.

No comments:

Post a Comment

Featured

Selenium - Page Object Model and Action Methods

  How we change this code to PageObjectModel and action classes. 1 2 3 driver . findElement ( By . id ( "userEmail" )). sendKeys (...

Popular Posts