mock server in Postman
Reading Time: 5 minutes

This post contains my Postman tutorial notes that I have created while learning the Postman tool.

This tool is used for learning and doing API testing though it has various features.

The official sites define Postman as – The Collaboration Platform for API Development

You can use the below notes to revise the things you have already learned and not using Postman for some time.

if you don’t have any idea about API testing / Postman, you can scroll through and go to last and see the tutorial to get started with API testing via Postman

Note :- if you find any mistakes in my Postman tutorial notes, do comment, or ping me on LinkedIn, I will correct it.

What are some key features of Postman (related to APIs)?

  • Publish APIs
  • Automated Test Execution for APIs
  • Monitor APIs
  • Document
  • Design and mock
  • Debug
  • Code Generation in any language
Postman Major Features
Postman Major Features

What are some API basics?

API Basics
API Basics

What to remember about the Request?

Requests in Postman
Requests in Postman

 

What all things API Response Contains?

API Response
API Response Major components

What are headers in Postman?

Headers in API
Headers in API

Where to see logs for the request run?

Console in Postman
Console in Postman can show these things

Why and when to use collections in postman ?

Collections In Postman
Postman-collections (Test Suite Concept)

What are the various kinds of variable in Postman?

All types of Variables in Postman
All types of Variables in Postman

What is Postman Sandbox?

It provides you a way to write code inside Postman.

Sandbox in Postman
Sandbox in Postman

What are tests in Postman?

  • JavaScript code
  • Only runs after request is run. Pre-Requisite script runs before the request and Tests run after the requests

Examples
    tests["Status code is 200 "] = responseCode.code === 200

Functional method with the name given to test method

   pm.tests("testing title",function() {console.log("Hello" });

How to run APIs via command line ?

Newman provides the way to learn your API suite(Collections) without opening Postman. Newman has few additional features which even Postman does not have.

You can use this via command line

newman run collectionJsonFileName

Newman in Postman
Newman in Postman

What are some assertions/tests that can be applied on response?


pm.test("REsponse should contain the key 'token",function()
{
var jsondata = pm.response.json();
pm.expect(jsondata).to.have.property("token")
});
pm.test("Token must not be null",function()
{
var jsondata = pm.response.json();
var flag = jsondata.token == null;
pm.expect(flag).to.equal(false);
});
pm.expect(pm.response.headers.get("Server")).to.eql("Cowboy")
pm.expect(res.lastname).to.not.equal("Jonesa");
pm.expect(res.totalprice).to.be.above(100);
pm.expect(res.totalprice).to.be.below(500);
pm.expect(parseInt(bookingID)).to.be.a("number")
pm.expect(jsonReq["booking"]["bookingdates"]["checkin"]).to.eql(jsonRes["created-booking"]["booking"]["bookingdates"]["checkin"])
pm.response.to.have.status("OK")
pm.response.to.have.status(200)
pm.expect(pm.response.code).to.equal(200)
pm.expect(pm.response.status).to.equal("OK")
pm.expect(pm.response.code).to.be.oneOf([201,200])
pm.expect(pm.response.status.toLowerCase()).to.equal("OK".toLowerCase())
pm.expect(pm.response.responseTime).to.be.below(25000)
pm.expect(pm.response.responseTime).to.be.above(199)
pm.expect(_.inRange(pm.response.responseTime,20,20000)).to.eql(true)
pm.expect(pm.response.responseSize).to.not.equal(0)
pm.expect(pm.response.text()).to.include("lastname")
pm.response.to.have.header("content-type")
pm.expect(pm.response.headers.get("Content-Type")).to.eql("text/html; charset=utf-8")
pm.expect(pm.response.json()).to.be.an("array")
pm.expect(pm.response.json()).to.be.an("object")
pm.expect([2]).to.be.an("array").that.is.empty
pm.response.to.be.badRequest;
pm.response.to.be.json;
cookies
pm.expect(pm.cookies.has("VstsSession")).to.be.true;
pm.expect(pm.cookies.get("VstsSession")).to.be.equal("12345")

How to deal with json response in Postman?

This would help a lot if the response you are dealing with is a Json.

Parsing Json Response in Postman
Parsing Json Response in Postman

What are some inbuilt functions provided by Postman APIs which can help in our tests?

Postman Global APIs functions
Postman Global APIs functions

What is the way to run all APIs together from Postman UI?

Collection Runner in Postman
Collection Runner in Postman

What is a mock server and where can it help ?

mock server in Postman
mock server in Postman

Full mind map for POSTMAN

Some of the things related to Postman are only present in mind map and not above

(Right click on this image and open in new tab to see the details properly)

Postman Mindmap
Postman Mindmap

HTTP Status Codes – Udzial  – my Other post about Status code related to API and questions are often ask in interview for this.

As a tester we should be aware about the major codes that we face while testing APIs

Where to learn Postman? or where to start learning API testing?

I have learnt Postman from the first 2 links. API testing is one of the essentials skills for software testers.

Postman provides an easy interface to get started with API automation.

After this you can use Rest Assured (Java) or Requests(Python) to do API testing programmatically

Postman Tutorials – Make Selenium Easy

Postman Tutorial for Beginners to perform API Testing (toolsqa.com)

Other good places(video Tutorial) to start learning API testing with Postman.

All the below listed courses are designed by people who have good knowledge in software testing as per my analysis.

POSTMAN BEGINNER TUTORIAL 2 💡 Understanding POSTMAN UI – YouTube

How To Download and Install Postman In Windows- Postman Tutorial For Beginner – YouTube

API Testing Using Postman: Part 1 ( What is an API? ) – YouTube

How to write API test cases in Postman using JavaScript – YouTube

If you like the post, do subscribe to my channel and blog. You may leave a comment too for any corrections/suggestions/appreciation

 

Related Posts

One thought on “Postman Tutorial Notes

Leave a Reply

Your email address will not be published. Required fields are marked *