loading...
Cover image for API Testing with Postman

API Testing with Postman

em_elkan profile image E Elkan Updated on ・2 min read

Recently I've been learning all about API testing with Postman. I've put together a small collection of my favourite tutorials and practice API's for anyone else who is new to API testing and wants to learn more.

What is Postman?

Postman is currently one of the most popular tools used in API testing. It's free for individuals and small teams with wide support for all API types. It can be used for exploratory testing and automated testing.

Tutorials

The Postman Learning Center
Exploring Service APIs Through Test Automation
API - Testing Tips from a Postman Professional
Testing APIs with Postman: 10 common challenges & solutions

Practice API's

PokéAPI
Restful-Booker
JSON Placeholder
The Star Wars API
Rick and Morty API

Code Snippets

Check Status code is 200:

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

Check response time is below 300ms:

pm.test("Response time is less than 300ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(300);
});

Check a value is true:

pm.test("Check Connected is true", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.Connected).to.eql(true);
});

Check values within an array:

pm.test("First group in list is Test 1", function () {
    var json = pm.response.json();
    pm.expect(json[0].Name).to.eql("Test 1");
    pm.expect(json[0].State).to.eql(3);
    1pm.expect(json[0].Type).to.eql(1);
});

Check nested values:

pm.test("Check ability is torrent", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.abilities[0].ability.name).to.eql("torrent");
});

Newman

Newman allows you to run and test a Postman collection directly from the command line. Newman can be used for continuous integration.

newman.gif

Postman Alternatives

soapUI
Postwoman
Insomnia

Cover image: https://icons8.com/

Discussion

pic
Editor guide
Collapse
larswww profile image
larswww

I found postman annoying at first, however what really changed my mind is the command-line version newman, and the ability to export the entire test suite in json files, with environments. Makes it so easy to share in a github repo and now the whole team can benefit from using the same suite!

Collapse
em_elkan profile image
E Elkan Author

Agreed. Newman is great, thanks for mentioning it.