anvoqa / postman-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

postman-api Postman JavaScript

About

This repo contains the Postman collection that I implemented in Postman desktop and exported as .json file to demonstrate my experience in API testing using Postman. The collection can be found here.

The Application Under Test (AUT) is the Contact List App: https://thinking-tester-contact-list.herokuapp.com/

The API documentation can be found here: https://documenter.getpostman.com/view/4012288/TzK2bEa8#intro

In addtion, before actually implementing the tests, I also developed the test plan to list out what tests will be done, the goal of each test, details of implementation and the expeced results. The test plan can be found here.

End to End Flow

  1. Send POST request to register an account
  2. Send POST request to login to the registred account and get the logged in token to be used in later requests
  3. Send GET request to get user profile
  4. Send PATCH request to partially update user (e.g. First Name)
  5. Send POST request to create a new contact
  6. Send GET request to get the contact list
  7. Send GET request to get a specific contact
  8. Send PUT request to update a contact
  9. Send PATCH request to partially update a contact
  10. Send DELETE request to delete a contact
  11. Send DELETE contact to delete the user

📖Knowledge📖

  • Use Postman to create POST, GET, PUT, PATCH, DELETE requests and write tests to veriy status code and data in body of responses
  • Use dynamic variables to generate random test data so that tests can be run many times without conflict and failing
  • Use pm object to get, set collection variables in Pre-request Script, Body and Tests
  • Use Postman.nextRequest() to set the order of requests when running collection
  • Use Monitor to schedule the collection to run once a week on a specific date/time and send email notification when there are failures
  • Use Newman to run the collection in CLI, and newman html extra report to generate test report when running test using Newman
  • Use Performance feature of postman to run the performance of end to end test flow and view the performance metrics

How to run the collection

With Postman Desktop App

  • Install Postman app
  • Download the collection "Contact List API Test.postman_collection.json" from this project
  • Import the collection to Postman app
  • Run the collection

With Newman using CLI

  • Install Newman npm install -g newman (remember to install Node.js to use npm)
  • Run the collection using the command `newman run "Contact List API Test.postman_collection.json"

Generate test report with htmlextra

  • Install htmlextra reporter: npm install -g newman-reporter-htmlextra
  • Run the collection using the command newman run "Contact List API Test.postman_collection.json" --reporters cli,htmlextra
  • The report will be generated in the newman folder which is the same location as postman collection

image

Performance testing using Postman

Postman has just introduced Performance Testing recently. It provide ability to run the entire collection by the pre-defined concurrent virtual users within a set period of time.

image

While the tests are running, user can view the real time report showing the trend of the performance as well as the metrics of each individual request

image

User can also check the error rate and when error happens

image

About


Languages

Language:HTML 100.0%