facebook Skype Linkedin
Skip to content
Home » Postman » How to use Postman for API test automation. Part I – First test

How to use Postman for API test automation. Part I – First test

postman-320x132

Postman becomes more and more popular tool for API so we decided to do a small series of posts on our experience and best practices on how to use this tool for API testing. This series will be useful for developers as well as for QAs. As you will get some new approaches that can be used in order to quickly write and validate you API.

In order to show how to use Postman you will have to download a postman application which is available for Mac OS, Windows x32, Windows x64, Linux x32, Linux x64  and as a Chrome plugin. To show you most basic functions of Postman we will use The Star Wars API this is a simple API that returns a data for all characters, planets and many more from Start Wars universe. So lets get started.

First of all install Postman application (links for each OS is above) and sign up or  log in into application. You will see something like this when you are ready to use application :

Screen Shot 2017-08-08 at 6.48.33 PM

So what do we have here? On a left hand side there is a column with all your saved collections(test sets). In a middle we have a dropdown that has a request type, URL and “Send” button. This is a part that we will work the most from now on. Also we have environment dropdown at the right top corner of application. But we will come back to environments later and now let’s run our first request using Postman.

Type in “https://swapi.co/api/planets” in to “Enter request URL” field and hit Send. You should see something like this in response :
Screen Shot 2017-08-08 at 7.03.55 PM

As you can see a response status is 200 OK and response time is 1290 ms(1.29 sec) and we have 61 items in our collection (61 planets in Start Wars universe). After that we have a whole bunch of planets in a list called “results”. As we have successfully executed our first request. Now let’s try to write our first test and execute request again.

We will try to add two tests for response code in order to know that our request was successful. Another test we will add for response time <  2 sec in order to understand how fast request was processed by server. If it will be executed slower then for 2 seconds, our test will fail. In this case I use 2 seconds just for example it might be greater or lower number, but 7 seconds is usually a maximum time for request execution. So in order to add tests, go to “Tests” in request section of application and add this few lines :

tests["Status code is 200"] = responseCode.code === 200;
tests["Response time is less than 200ms"] = responseTime < 2000;

When this is done hit on Send button again and execute your first test. Result should look like this :
Screen Shot 2017-08-08 at 7.17.24 PM

Conclusion

Dive into the world of API test automation with confidence using our Postman tutorial. For more insights and to unlock the full potential of your digital solutions, visit our website and continue exploring our blog. Join us at Scimus, where innovation meets expertise.We will continue on more advanced tests and postman functions in a next part.

Thank you for attention and hope it was useful for someone out there!

Leave a Reply

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

Subscribe to our Newsletter