API integration testing using Postman, Newman, and Jenkins Pipeline
In this story, we’ll explain the API integration testing solution step by step using Postman, Newman, and Jenkins pipeline.
This story shows how to set up a Jenkins pipeline that uses Newman to run a Postman collection.
Prerequisites
This is the list of all the prerequisites for following this story:
- A GitHub repository
- Git
- Jenkins instance installed
- Node JS
- NPM
- Postman
Overview
What is Postman?
Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs — faster.
What is Newman?
Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.
What is Jenkins?
Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.
Getting started
1- Postman collection
Open postman -> File -> New -> Collection
Then, inside the collection, we will create the different requests that we want to test on our API. For this story, we will use the fake “JSONPlaceholder” API endpoints.
With Postman we can add scripts to each request. Testing confirms that our API is working as expected, integrations between services are working reliably, and changes have not broken existing functionality.
The Pre-Request Script tab will run before our request is sent, and the Tests tab will run after we receive our response.
Tests are scripts written in JavaScript that are executed after a response is received. Tests can be run as part of a single request or run with a collection of requests.