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
What are some API basics?
What to remember about the Request?
What all things API Response Contains?
What are headers in Postman?
Where to see logs for the request run?
Why and when to use collections in postman ?
What are the various kinds of variable in Postman?
What is Postman Sandbox?
It provides you a way to write code inside 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
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.
What are some inbuilt functions provided by Postman APIs which can help in our tests?
What is the way to run all APIs together from Postman UI?
What is a mock server and where can it help ?
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)
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
Hello! My name is Gaurav Khurana. I have 12+ years of experience as a Software Tester. Won the Tester Of the Year Award 2022. Currently working for Microsoft. Worked in 2 MNCs. A youtuber and blogger and worked on *nix and windows based apps for telecom & insurance domain. Used Selenium, Serenity-bdd, RestAssured, AzureDevOps, Karate, SoapUI, Perl, Shell scripting, Postman, TestProject for automation,etc along with excel. Udzial is a polish word which means share. I believe in #SharingIsCaring.
One thought on “Postman Tutorial Notes”