Testing Web and Micro Services with Postman Request in NodeJS

Testing Web and Micro Services with Postman Request in NodeJS

More and more organizations now move towards developing software solutions via Web and Micro Services. Its is the most versatile way of delivering software solution for customers or third parties which will take such services and integrate to their UIs in the way they want. For example, Google develops large amount of Web Services for Google Maps, Google Search etc, which are used by other software vendors.

Testing of such services is utmost important as a failure in a Web Services will create trivial disasters.

We are now in an era of test automation and concentrating automating the testing of Web Services and Micro Services.

We are having the comfort of automation of Web Services with a vast array of tools. SOAP UI, REST Assured being some.

In this article I will be covering another fantastic Web Services testing tool in NodeJS, called Postman. This is the NodeJS version of Postman tool that we use to test Web Services.

To kick start the use of Postman Request, lets first install the module with the following npm command.

npm install postman-request

Next lets script the web services test scenario in Java Script, where we access the web service in NASA.

var request = require('C:/Users/kam/node_modules/postman-request');
request('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY', function (error, response, body) {
  console.log('error:', error); // Print the error if one occurred
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  console.log('body:', body); // Print the HTML for the Google homepage.
});
 
  

Since we are now in a perfect move, lets execute the scenario using the following node command.

C:\slimerTest\httptest>node C:\slimerTest\httptest\kushan6.js

Once execute the success code 200 along with the response will be displayed in the command line.



Rishikesh Patil

SWE @ Fidelity Investments || AWS Certified || UTD 2023

6 年

Can we use Postman for applications developed using Microservices architecture too??? For Contract Testing??

SUYASH NANDE

Developing Tools for Software Productivity and Enablement

6 年

I often use this, it's the simplest.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了