Postman Tutorial For Beginners
Postman Tutorial For Beginners
What is Postman?
Why Use Postman?
How to use Postman
Working with GET Requests
Working with POST Requests
How to Parameterize Requests
How to Create Postman Tests
How to Create Collections
How to Run Collections using Collection Runner
How to Run Collections using Newman
Step 5) Select the workspace tools you need and click Save My
Preferences
Step 6) You will see the Startup Screen
We will use the following URL for all examples in this tutorial
https://jsonplaceholder.typicode.com/users
In the workspace
Step 3) In Body,
1. Click raw
2. Select JSON
Step 4) Copy and paste just one user result from the previous get
request like below. Ensure that the code has been copied correctly
with paired curly braces and brackets. Change id to 11 and name
to any desired name. You can also change other details like the
address.
[
{
"id": 11,
"name": "Krishna Rungta",
"username": "Bret",
"email": "Sincere@april.biz
",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
}
]
*Note: Post request should have the correct format to ensure that
requested data will be created. It is a good practice to use Get
first to check the JSON format of the request. You can use tools
like https://jsonformatter.curiousconcept.com/
Step 5) Next,
1. Click Send.
2. Status: 201 Created should be displayed
3. Posted data are showing up in the body.
Step 1)
Step 3) In variable,
Let's create some basic tests for our parameterize requests from
the previous lesson.
1. Switch to the tests tab. On the right side are snippet codes.
2. From the snippets section, click on "Status code: Code is
200".
Step 3) Go back to the test tab and let's add another test. This
time we will compare the expected result to the actual result.
1. Replace "Your Test Name" from the code with "Check if user
with id1 is Leanne Graham" so that the test name specifies
exactly what we want to test.
2. Replace jsonData.value with jsonData[0].name. To get the
path, check the body in Get result earlier. Since Leanne
Graham is userid 1, jsonData is in the first result which
should start with 0. If you want to get the second result, use
jsonData[1] and so on for succeeding results.
3. In to eql, input "Leanne Graham"
Step 5) Click send. There should now be two passed test results
for your request.
*Note: There are different kind of tests that can be created in
Postman. Try to explore the tool and see what tests will fit your
needs.
Step 1) Click on the New button at the top left corner of the
page.
Step 2) Select Collection. Create collection window should pop
up.
Step 5)
Step 1) Click on the Runner button found at the top of the page
next to the Import button.
Step 2) Collection Runner page should appear such as below.
Following is the description of various fields
1. Once tests have finished, you can see the test status if it is
Passed or Failed and the results per iteration.
2. You see Pass status for the Get Requests
3. Since we did not have any tests for Post, there should be a
message that the request did not have any tests.
You can see how important it is that there are tests in your
requests so that you can verify HTTP request status if successful
and the data is created or retrieved.
To install Newman and run our collection from it, do the following:
cd C:\Users\Asus\Desktop\Postman Tutorial
Summary
Postman is currently one of the most popular tools used in
API testing
Accessibility, Use of Collections, Collaboration, Continuous
Integration, are some of the Key features to learn in Postman
It's recommended you create an account in Postman, so your
collections are available online
You can parameterize request in Postman
You can create Tests to verify a postman request
Collections can be run using Newman or Collection Runner