6 Reasons to use Postman/Newman for API Integration Testing

Jun 22, 2016 4:55:32 PM / by Michael Fried

Michael Fried

You wrote a fancy new API that handles everything you can throw at it. You spent hours doing manual testing to make sure your API works perfectly. You release your code and make some updates. Now you have to spend hours manually testing again. There has to be a better way. Here are 6 reasons you should use Postman and Newman for API integration testing.

1. Easily create test suites

Postman allows you create collections of integration tests to ensure your API is working as expected. Tests are run in a specific order with each test being executed after the last is finished. For each test, an HTTP request is made and assertions written in javascript are then used to verify the integrity of your code. Since the tests and test assertions are written in JavaScript, we have freedom to manipulate the received data in different ways, such as creating local variables or even creating loops to repeatably run a test.

Here we can see the default collection that comes with Postman:

blog_pic_1.png

2. Store information for running tests in different environments

You wrote your test collection and it all works perfectly. You can run it again and again against your local environment and every test passes every time. But your local environment is usually configured a little differently than a test server. Luckily, Postman allows you to store specific information about different environments and automatically insert the correct environment configuration into your test. This could be a base URL, query parameters, request headers, and even body data for an HTTP post.

blog_pic_2.png

3. Store data for use in other tests

Postman also allows you to store data from previous tests into global variables. These variables can be used exactly like environment variables. For example, you may have an API that requires data received from another API. You can store the response (or part of the response, since it is JavaScript) and use that as part of a request header, post body, or URL for the subsequent API calls.

Below we can see the "auth_token" variable being stored and then used in the next test.

blog_pic.png

4. Integrates with build systems, such as Jenkins using the Newman command line tool

Postman has a command line interface called Newman. Newman makes it easy to run a collection of tests right from the command line. This easily enables running Postman tests on systems that don’t have a GUI, but it also gives us the ability to run a collection of tests written in Postman right from within most build tools. Jenkins, for example, allows you to execute commands within the build job itself, with the job either passing or failing depending on the test results.

blog_pic_5.png

5. Easily move tests and environments to code repositories

Postman makes it easy to share and move tests into different systems and environments by encapsulating collections in a "test" file and an "environment configuration" file. You can also export a test collection and use traditional filesharing to move it from environment to environment. This also makes it extremely simple to use code repository tools such as Git or SVN to manage the Postman tests and environment files, as well as maintaining version history in case you need to roll back changes.

6. On-the-fly testing

Any time you write some code, you’ll want to incrementally run it to make sure there aren’t any bugs or typos. Postman makes it easy to do just that. Postman lets you write a test without needing to put it in a collection, save it, or back it up. You just make a request to a URL, then see the result. Postman even parses JSON data to make it a little easier to read.

blog_pic_2.png


Postman is a powerful tool for performing integration testing with your API. It allows for repeatable, reliable tests that can be automated and used in a variety of environments and includes useful tools for persisting data and simulating how a user might actually be interacting with the system.

To learn more about automated testing and to become an ICAgile Certified Professional in Agile Testing, check out our courses.

Learn More

 At AgileTrailblazers – WE GET AGILE®.

 

 

Learn more about modernized technology here:

Develop solutions with speed/quality


 


Interested in training to help advance your agile journey? Click the button to view our current list of public training courses! Use code BLOG10 for 10% off!

View Public Training Course Listing

 

 

 

Topics: Test Management, Modernized Technology, Software Delivery, Postman, Newman, API

Written by Michael Fried

Michael is a software development engineer here at AgileTrailblazers. With a focus on Java and J2EE development, Michael has experience working with a wide variety of software/web development technologies ranging from HTML/XHTML/JSP to Object Oriented and Functional programming languages to SQL and database management to deploying applications on a variety of servers. Graduating Drexel University with a BS in Software Engineering, Michael went on to develop for Lockheed Martin and Fiserv before joining Agile Trailblazers in February.

Subscribe to Email Updates

Lists by Topic

see all