The expected outcome is a Postman collection covering the testing of one of the 4 REST API resources available on https://gorest.co.in/
.
The authentication token for the requests can be generated on https://gorest.co.in/consumer/login
or on https://dummy.restapiexample.com/
(as an alternative in case the first one doesn’t work for you)
You are expected to:
- Cover as many testing levels and types as possible to make sure your tests are catching all potential critical defects
- Enable the testing of the provided functionality as part of a CI/CD pipeline (hint: Postman collections can be executed via newman)
- Describe the chosen API testing approach
- Provide execution instructions and enough information explaining the final solution
- An extra bonus is considered developing an automation framework covering the scenarios from the Postman collection --> This was implemented here: https://github.com/arielmachado-uy/ultra-api-challenge
1. Cover as many testing levels and types as possible to make sure your tests are catching all potential critical defects
List of devised scenarios
Positive scenarios
- Create new user
- Update user's values
- Delete user
Negative scenarios
- Get user by ID - not found
- Update user - not found
- Delete user - not found
- Create new user with empty fields
- Create new user with wrong values
- Create new user with a repeated email
- Request with incorrect token
- Request with incorrect url
These positive and negative scenarios execute all the posible requests in the API
- POST /public/v2/users
- GET /public/v2/users/1629
- PUT /public/v2/users/1629
- DELETE /public/v2/users/1629
- GET /public/v2/users
After the execution of every request some validations are performed to the response
- Validate response status
- Validate response values
- Validate response schema
- Validate the values stored at the environment level
2. Enable the testing of the provided functionality as part of a CI/CD pipeline (hint: Postman collections can be executed via newman)
Newman-Postman automation project
Repository link: https://github.com/arielmachado-uy/ultra-postman-challenge
Automation files
- Postman collection:
ultra_collection.json
- Postman environment file:
ultra_environment.json
CI/CD implementation
- This project runs an entire Postman collection using Newman
- The automation project is integrated with github actions for CI/CD
- The automated test case will run after every push to the
main
branch - The automated test case can be run manually using the github workflow
All the scenarios were created in a way that can be executed in series from top to bottom
Positive Scenarios
- Create new user
- Uses a
POST
request to create a user - Uses a
GET
to retrieve all the users and validate that the last one is the newly created
- Uses a
- Update user's values
- Uses a
GET
to find a user by its ID - Uses a
PUT
to update the user's data - Uses a
GET
to find a user by its ID and validate the updated values
- Uses a
- Delete user
- Uses a
DELETE
to remove the user
- Uses a
Negative Scenarios
- Get user by ID - not found
- Uses a
GET
to try to find a user with a not existing ID - Returns 404
- Uses a
- Update user - not found
- Uses a
PUT
to try to find a user with a not existing ID - Returns 404
- Uses a
- Delete user - not found
- Uses a
DELETE
to try to find a user with a not existing ID - Returns 404
- Uses a
- Create new user - empty fields
- Uses a
POST
to try to create a user with empty fields - Example: "name": ""
- Returns 422
- Uses a
- Create new user - Wrong values
- Uses a
POST
to try to create a user with wrong values in some fields - Example: "gender": "blablabla"
- Returns 422
- Uses a
- Create new user - Repeated email
- Uses a
POST
request to create a user - Uses a
POST
to try to create another user with the email address of the previous user - Uses a
DELETE
to remove the user - Returns 422
- Uses a
- Create new user - Incorrect token
- Uses a
POST
to try to create a user using an incorrect token - Returns 401
- Uses a
- Create new user - Incorrect url
- Uses a
POST
to try to create a user with an incorrect api url - Returns 404
- Uses a
Postman implementation
Postman setup
To run the collection inside postman, follow these steps:
- Open postman
- Import the collection file
- Import the environment file
- Click on the 3 dots next to the collection name and select
Run collection
- Leave all the requests selected and click on the name that says
Run
and the name of the collection (in my case it saysRun Ultra.io
) - After the execution finishes, you will get the results of the execution as in this image
Automation implementation
Project setup
- Checkout the code from the provided url (https://github.com/arielmachado-uy/ultra-postman-challenge)
- Open the project on VS Code
- Open the terminal and run
yarn
in order to install needed dependencies
Project execution
- There is a script in the package.json file to run whole collection using newman
yarn pm:run
Information about the project implementation
The script will use the attached collection file to run the requests contained in the Postman collection and consuming the variables from the attached postman environment variable
The script will run the collection from top to bottom as if we were running it in Postman and then return the results