Contact Us
VISIT US: USA
2890 Zanker Road, Suite 200, San Jose, CA – 95134
MAIL US:
[email protected] (Inquiry)
CALL US 24/7:
+1 510 358 4310

Latest Blogs

  • Break The Connectivity Barriers with Wi-Fi 7
  • Intelligent Health Environment
  • AI-Driven Quality Engineering
  • Complete Guide to Develop a Home Automation App
  • Machine to Machine Communications
  • Safe RTOS

Best Practices for Successful API Test Automation using Postman

September_27_2019

API stands for Application Programming Interface which is used to smoothen the interaction between two different application by using any mode of communication. Every time you check the weather or a train time on your smartphone, you’re making use of APIs that enables your smartphone app to pull information from the weather bureau’s applications or the train operator’s train tracking and timetabling systems.

APIs are also helpful in controlling hardware devices and software functions that an application may not necessarily have permission to use. That’s why APIs often play a big role in security.

APIs are an integral part of IoT world that integrates Mobile App with Real devices. APIs acts as a glue that help connect devices, products, facilities, assets and other objects with the applications that make use of the data they generate.

The integration of all devices in IoT is all about API — the interoperable logical connection that allow applications to communicate with each manufacturer’s IoT devices. APIs provides data that enables those devices to transmit data to the end applications, acting as a data interface. Also, they can allow the end application to control the device and serve as a function interface.

Why Testing APIs?

Since APIs is critical in terms of data and works as a bridge between App and Device, they need to be tested to ensure that the data is represented correctly. A perfect working API leads to the perfect working application. Testing the API solves a lot of issues in the application which may arise at some point of time in future. There are many software’s available for API Testing and one such software is Postman.

API Automation Testing using Postman:

Postman is a platform that allows us to develop, use as well as test Rest APIs. It is available as an extension of Chrome and can be downloaded from the following
URL: https://www.getpostman.com/downloads/

Key Highlights:

  • Postman allows to create collections of integration tests to ensure that API is working as expected. For each test, an HTTP request is made and assertions written in javascript are then used to verify the integrity of code
  • Postman provides list of assertions and 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 repeatedly run a test
  • Postman also allows us to store data from previous tests into global variables. These variables can be used exactly like environment variables. For example, there is an API that requires data received from another API. We 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
  • With the help of Postman, we can reuse the code(assertions) written for one environment to multiple other environments
  • Once developed it needs no maintenance and can be verified at any point of time without any changes

Newman CLI:

Once the Postman collection runner is ready, it requires to export the collection and execute it from the command Line using Newman. Newman publishes report aa handful after the execution which can give a fair idea of API failures along with the detailed information.

Key Highlights:

  • Newman allows to run and test a postman collection directly from the command line
  • It is extensible and hence we can easily integrate it with our continuous integration servers and build systems
  • It comes with a Report giving complete information of the execution

Newman is built on Node.js which can be downloaded from the following
URL: https://nodejs.org/download/

Once we have Node.js installed, Newman can be now installed in the machine using the following command : “npm install -g newman”. It can be extended further for receiving wonderful reports using “newman-reporter-htmlextra” that include the separation of the iteration runs and not aggregated together and also some additional handlebars helpers to enable users to create better custom templates.

In order to trigger the execution through Command line with following command:

“newman run “APITests.postman_collection” –environment “ClearbladeTest.postman_environment” -r htmlextra –reporter-htmlextra-title “Newman Run Dashboard”.

Below image shows the dashboard of the report :

VOLANSYS-dashbord-report

Automated Tests Execution using CI:

To complete the entire procedure and make it fully automated from triggering to reporting, we will need to integrate the process with Continuous Integration called Jenkins. As and when development code gets deployed, it can be tested, and the execution of API tests can be done auto triggered through Jenkins. The report of the test execution will be received in the mail box.

Real Time Cloud API Defects:

API Automated Testing results into real time bugs which can be fixed prior to production release and thereby increasing code efficiency and reducing defects in the System. Eg. there was an issue wherein user wasn’t able to delete location/equipment from the App and it was reported prior through API Test Results which helped us maintaining code quality as well as App quality.

Conclusion:

API test Automation enables communication and data exchange between two separate software systems. A software system implementing an API contains functions/sub-routines which can be executed by another software system. It helps in creating more robust and bug-resistant programs by increasing test coverage and frequency.

For more details on our Quality Engineering Services, click here.

See how we have helped our esteemed clients to ensure quality of their product – Read Case Studies.

VOLANSYS-sharadha-shah
About the Author: Shraddha Shah

Shraddha is associated with VOLANSYS Technologies as a QA Automation Lead for more than 2 years. She has vast experience in Web, Mobile and Cloud Automation testing domains.

Recent Posts

Break The Connectivity Barriers with Wi-Fi 7

Break The Connectivity Barriers with Wi-Fi 7

In an increasingly digital world, a robust and lightning-fast internet connection has become more essential than ever. J
Read More
Intelligent Health Environment

Smart Healthcare: A New Way for Intelligent Health Environment

Emerging technologies like artificial intelligence (AI) and machine learning are transforming almost all industries, hea
Read More