arrow_back

6 Reasons to use Postman/Newman for API Integration Testing

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 CirrusLabs – 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