Continuous Integration and Testing Using Postman With Jenkins
Using these tools in combination can create a working continuous REST API testing instance.
Join the DZone community and get the full member experience.
Join For FreeContinuous integration and testing are the key terms to integrate all the phases of the development lifecycle and deliver working product/software to a client at the earliest possible time using tools like Jenkins. Here, you will get to know about performing continuous REST API testing using Postman with Jenkins tools.
Postman is a tool used to develop, test, share, monitor the performance of an automated test and document API’s. Follow the below steps to integrate Postman with Jenkins for continuous integration and testing.
Step 1: Use this link to install Postman for Windows.
Step 2: Create collections in Postman.
Collections are used to create and store series of API request and can be executed altogether. I am taking a dummy REST API for creating collections in Postman.
After you create the collections in Postman, export it and save it in your local system. The exported API test collection can be executed from the Command Line Interface (CLI). Let's see how to execute the Postman collections from the CLI.
Type the below command from command line interface to install Newman, post to that installation we can able to execute collections from CLI (Command Line Interface).
npm install -g newman
Note: Ensure Node.js for windows should be available in your system to install newman. Node.js can be installed from https://nodejs.org/en/download/
Step 3: Execute Collections from Command Line Interface
From the command line interface, just go to the location where you have stored/exported collections in your local system. Use the below command to execute collections from CLI,
newman run <collection name>
Example:
newman run EmployeeCollection.Postman_collection.json
Step 4: Integrate Postman Collection with Jenkins
- The first step is to download Jenkins from the official website
- Type the below command to install Jenkins from the command line:
java -jar Jenkins.war
Configure the build section with below command to execute Postman collections test:
Note: I entered 2 lines of command. The first line represents the location where we have collections saved and the second line executes collections created in Postman tool.
Click the "Build Now" option from Jenkins to execute every command from the build section one by one and you can see your collection result from Jenkins.
Configure Jenkins with the Build Triggers option to trigger the build every minute automatically so that Jenkins will check the latest change from the location where you have stored the Postman collection and it triggers the build automatically.
Opinions expressed by DZone contributors are their own.
Comments