fbpx

API Test Generator

Introduction

APIs should be functionally correct,  fast, secure, and reliable. Functional API tests are the equivalent of unit tests for software: a way to ensure that the API returns the desired output for a given input and most API tests also fall under the umbrella term “performance tests” because their purpose is to determine the overall performance of a system under specific circumstances.

Problem Statement for API Test Generator: What was the need for this? 

The customer had applications that needed to be enhanced over time. After every change in the app code, there was a need for regression testing, including performance testing. The non-automation testers were required to execute the performance test cases. There was a need to provide a tool that can be used by such non-technical people and provide a performance analysis of the system, so as to enable the development team to course correct in case the performance dropped below the expected parameters.

Solution Approach: 

We discussed the options and realized that the best way forward was to give inputs to a tool like Paw, Insomnia, etc, and let the tool do the job. However, since one of the major tasks was for the solution to be usable by non-technical team members, we felt the best way was to convert the postman collection into a Jmeter executable file. Thus we can export the postman collection and give it as input to the utility.

The Solution 

After considering all the options, API Test Generator which integrates API Functional testing with Performance testing was considered

Design Approach

Functionality

API Test Generator takes a minimum of two CSV files as input. One will be setup.csv and the other should be a collection(CSV). This will take all collection(CSV) files present in the same file location with different names but ending with a collection.

The utility reads a CSV file row by row and for each row construct an API call using rest assured. Request body repository can be maintained where one request body file path can be used by all collections(CSV). It allows data from one API response to be passed on to the next APIs using Jsonpath. Details of each API call are available in the execution report generated at the end of the run. This will execute performance tests with given parameters and generate reports each collection(CSV) and create Jmx files from the same API collection (CSV) file that can be loaded in Apache Jmeter for a performance test run.

Setup(csv)

Setup CSV will have data that will be common for all collection(CSV) files.

Collection(csv)

Collection CSV will have data where each row will define each API details that are needed to run through automation.

Final Output

For each row in the collection(CSV) we have a detailed report created after execution using rest assured.

Based on CSV performance parameters execution is done using an API provided by Apache JMeter and Reports are created in a separate folder where JMX file is generated that can be loaded in Jmeter and run again.

Final Performance Report generated with graphical representation.

Author: Kunal Lachuriye.



Author: Tanvir
An aspiring digital marketer, a passionate singer, a guitarist and a mechanical engineer by degree. It would be so cool if I had lots of fans but the ceiling space is limited. You can find me on LinkedIn.

Leave a Reply