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
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": "[email protected]
",
"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"
}
}
]
1. Click Send.
2. Status: 201 Created should be displayed
3. Posted data are showing up in the body.
Step 1)
Let's create some basic tests for our parameterize requests from
the previous lesson.
Step 1) Go to your GET user request from the previous tutorial.
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:
Step 6) We will also need to export our environment. Click on the
eye icon beside the environment dropdown in Global, select
Download as JSON. Select your desired location then click Save. It
is advisable that the environment should be in the same folder as
your collection.
Step 7) Environment should now be exported to the same local
directory as Collection.
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