0% found this document useful (0 votes)
10 views6 pages

Venkat Raj

The document discusses the development of a generalized test automation framework for REST API testing using Groovy script, aimed at reducing the time, effort, and cost associated with manual testing. The framework automates the testing process by reading input from an Excel file, making REST API requests, validating responses, and generating results, thereby enhancing efficiency and enabling continuous regression testing. The proposed solution addresses the inefficiencies of manual testing, particularly in scenarios where application functionalities change frequently.

Uploaded by

Abhishek Sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Venkat Raj

The document discusses the development of a generalized test automation framework for REST API testing using Groovy script, aimed at reducing the time, effort, and cost associated with manual testing. The framework automates the testing process by reading input from an Excel file, making REST API requests, validating responses, and generating results, thereby enhancing efficiency and enabling continuous regression testing. The proposed solution addresses the inefficiencies of manual testing, particularly in scenarios where application functionalities change frequently.

Uploaded by

Abhishek Sinha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/332652917

Development of test automation framework for REST API testing

Article in Journal of Computational and Theoretical Nanoscience · February 2019


DOI: 10.1166/jctn.2019.7749

CITATIONS READS

3 7,777

5 authors, including:

Rajiv Vincent Vasughi Vijayakumar


VIT University Chennai S.R.M. Arts & Science College
34 PUBLICATIONS 275 CITATIONS 24 PUBLICATIONS 110 CITATIONS

SEE PROFILE SEE PROFILE

K. Vengatesan Rajesh M
Sanjivani College of Engineering Vellore Institute of Technology
95 PUBLICATIONS 1,019 CITATIONS 36 PUBLICATIONS 274 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Rajiv Vincent on 31 May 2020.

The user has requested enhancement of the downloaded file.


Copyright © 2019 American Scientific Publishers Journal of
All rights reserved Computational and Theoretical Nanoscience
Printed in the United States of America Vol. 16, 453–457, 2019

Development of Test Automation


Framework for REST API Testing
S. Venkatraj1 , Rajiv Vincent1 ∗ , V. Vijayakumar1 , K. Vengatesan2 , and M. Rajesh1
1
School of Computing Science and Engineering, VIT University, Chennai 600127, Tamil Nadu, India
2
The Department of Computer Engineering, Sanjivani College of Engineering, Kopargaon 423603, Maharashtra, India

This work proposes a generalized excel based test automation framework for REST API testing
using groovy script. Testing is an important process in software development process, which helps
to find unknown errors, failure and bugs in a software application and increases quality of the soft-
ware application. With the existing process of testing is manual, where the inputs are given manually
and the actual outcome or output is validated for different test case scenarios. This manual testing
leads to increase in time and effort of testing, as there will be different scenarios to be tested in
which different test data has to be prepared to test a particular functionality. As the functionalities
in an application changes or added up, over the software development phase, there is a need to
test the old functionalities after and before, integrating the new or changed functionality to the exist-
ing system. This results in testing the already tested functionalities to test again manually, which
increases effort and time for the testing process. The manual testing process has to be automated,
so that the testing time, effort and money can be reduced. The test automation framework is imple-
mented using a groovy compiling tool in which the functionalities such as, read the data from input
test data excel file, make a REST API request, validate the data and writing the result to the excel
file has been developed. Since groovy is a flavor of java, several libraries have been imported to

RESEARCH ARTICLE
implement the test automation framework.
Keywords: REST API Testing, Test Automation Framework, Manual Testing, JSON Response,
API Test Automation Framework, API URL, Response Time, Actual Response Code.

1. INTRODUCTION the results are entered for a test. The process of sending
The testing process is a vital process for any application request, validating response and observing result is done
before it is going to be deployed or delivered. The testing manually for each test, which eventually increases effort,
process is done manually, where a continuous availability time and cost. This approach of manual REST API testing
of human effort is needed, to visually test the applica- becomes inefficient when a change occurs in the API. The
tion by giving different inputs for different scenarios. The testing process must be automated to increase efficiency
testers need to prepare test case document, prepare various and also to decrease effort, time and cost.
test case scenarios and prepare input data. For particular
a test, the expected and the actual outcome is compared 2. REVIEW OF LITERATURE AND
and the results are entered in the document manually. The RESEARCH GAP
testers must test again and again after a modification in API based testing requires a programming interface to
the application, which also increases time, effort and cost. test the application’s behavior which is to be tested. The
Having this as a base, the concept of REST API testing test scripts that are created separately are to be used by
to be known where a request to be sent and response is the automation framework to execute the validation as
captured and it is verified for errors. Format of request specified for a specific test. API automation yields 100%
and response is JSON. In REST API testing, the testing test coverage. Earlier detection of defects, effort put by
process is carried out by sending a request (input data) the manual testers is decreased. The test automation can
and observing the response returned from the API and be scheduled as a nightly build which tests the applica-
validating it with the expected response. After validation tion automatically if the numbers of test cases are more.
The API based test automation framework should produce

Author to whom correspondence should be addressed. results at the end with detailed information about passed

J. Comput. Theor. Nanosci. 2019, Vol. 16, No. 2 1546-1955/2019/16/453/005 doi:10.1166/jctn.2019.7749 453
Development of Test Automation Framework for REST API Testing Venkatraj et al.

and failed test cases. The actual values are to be captured containing data that are used to do automated testing for
and given by the framework for final verification by the validating REST API. The framework is designed in such
testers after the automation [1]. Automating the testing a way that it exports results in a separate excel file after
process increases the speed software development process. the automated is executed for a corresponding input file
The API test automation framework developed should be containing test data. The validation functions are created
generic as possible, where it should work for any applica- as a separate library file in which the framework calls the
tion’s developed REST APIs which can be reused for any appropriate validation function, as mentioned in the input
project in the future, which helps an organization to put excel file.
minimal effort on API testing [2].
This automated testing can have:
(1) Detailed test cases defined from the test case doc-
4. REST API TEST AUTOMATION
ument and expected results, preconditions for functional
FRAMEWORK ESSENTIALS
validation. 4.1. Test Data
This module contains the test data that will be read by the
A separate test environment is needed since the test cases
framework to do test automation of each test case scenar-
may increase and repeating the execution of test cases may
ios. The columns contained in the input test data excel file
increase. Also another advantage of automating the REST
used for test automation are as follows:
API testing is the implemented framework can perform
 Test ID
continuous regression testing.
 API URL
 Method
2.1. Aim of the Research  Pre-Condition
The main aim of this work is to automate the integration  Input data
testing process and reduce time and increase efficiency of  Action
testing.  Expected Result Description
 Expected Error Code
3. MATERIALS/METHODS  Expected Response Code
In the proposed architecture as shown in Figure 1, the  Actual Response
framework expects an excel file as an input with the file  Actual Error Code
RESEARCH ARTICLE

Fig. 1. REST API test automation framework architecture.

454 J. Comput. Theor. Nanosci. 16, 453–457, 2019


Venkatraj et al. Development of Test Automation Framework for REST API Testing

 Actual Response Code takes action, expected error code, expected response code
 Result. data field from the input test data to do the verification in
Test ID: the response returned from that API.
The test id which is a unique identifier for each test case The validation is done based on the value contained in
scenario referred from the test case document as per the the action column. The validation functions are defined in
standard is specified in this field. a separate groovy file. The framework does the validation
API URL: based on the validation mentioned in the action column
The API URL is used to make REST API request. Each of the test data. The framework calls the defined valida-
API will be having a specific URL with optional query tion function by sending the response returned from the
parameter as input. REST API request and expected values from the input test
Method: data file, as a parameter. The validation function validates
An REST API has a specific type of call to perform the parameters and returns whether “pass” or “fail” to the
an operation, the CRUD operations (Create, Read, Update framework. The validation function validates by parsing
and Delete). Based on the operation the method call is the actual JSON response and compares it with expected
specified in this field. The possible HTTP methods are value and returns the result, now the framework writes the
DELETE, PUT, POST and GET. actual response, actual error code, actual response code
Pre-Condition: returned from the request made and the result returned
from the called validation function. The framework cre-
The pre-condition that are to be satisfied before the test
ates a copy of the test data excel file and writes the actual
execution to be performed has to be defined in this field.
response, actual error code and actual response code and
Input Data:
the result that are returned.
The request data to be sent for a specific API request
The Table I shows the necessary inputs that will be read
has to be given in this field. The request data should be in
by the framework to do REST API test automation. The
JSON format.
framework uses the API URL and method from the above
Action:
table to make a REST API request. The request body for
The validation to be performed is given in this field, say
the particular REST request was taken from the test data
“responsecodevalidaton.”
field in the Table I. The action will give the type of vali-
Expected Result Description:
dation to be done for a particular test. Similarly there will
The description for the expected result, what has to be
be ‘n’ number of test cases in each row, having values

RESEARCH ARTICLE
verified in the response for the test has to be defined in
for each field. The framework reads row by row and tests
this field.
automatically till the end of input test data excel file.
Expected Error Code:
The expected error code, the error code is verified with
4.3. Test Result
response, for negative scenario test cases has to be speci-
fied in this field. The test result is the replica of the test data where the left-
Expected Response Code: out columns like actual response, actual error code, actual
The expected response code for a specific API request, response code and results columns are filled by the frame-
which has to be verified, is specified. work after execution of test automation. The result whether
Actual Response, Actual Error Code, Actual Response passed or failed will be written by the framework for each
row containing each test case of different scenarios. The
Code, Result:
actual response, actual error code and actual response code
These fields are initially left empty, which will be filled
and result are also written in the test result file. The testers
by the framework to produce results for all the test cases
will observe the results written by the framework for each
contained in the test data file.
test case in the test result file. By this it helps the testers
Each row in the excel is a test case which will be having
to observe the results and report the failed test cases to the
values for all these above-mentioned fields, which serves
development team to fix the error or the detected bug.
as an input for the framework to automate each test case.
The Figure 2 shows the step by step process flow of the
framework. For each test, the operations in the flow dia-
4.2. Framework
gram will be carried out and the result will be recorded or
The test automation framework is developed using groovy
script. The framework is responsible for getting the test Table I. Sample input data for the framework.
data as input and automates the test case and produce
test result file. In order to make a REST API request-API API Url Method Test Data Action
URL, method, and request data are needed. The frame- http://apiendpoint/ POST { error code
work takes these data from the input test data file as an login Username: ”john”, and
input and makes the REST request and gets response and password:”john” response code
} validation
uses it for validation. In addition to that, the framework

J. Comput. Theor. Nanosci. 16, 453–457, 2019 455


Development of Test Automation Framework for REST API Testing Venkatraj et al.

Table III. Sample input expected values for validation.

Expected Expected Expected


Expected record error response Response
result Count code code time

Error code 103 103 401 00.00.00.7


and response
Code 401 53

Fig. 3. Analysis of response time for each REST API request.

developed for validation. The Table II shows the sample


results generated by the API test automation framework
where actual values are filled by the framework. The actual
record field has the JSON response returned by the API.
RESEARCH ARTICLE

The actual response code is the status code returned by the


API and the result column has the “pass” or “fail” value
for the sample test specified in the Table I. Similarly the
mentioned fields for all the test cases in the input test data
file are filled by the framework.

5. RESULTS AND DISCUSSION


At the end the result file containing the actual values
responded by the API and the validated result will be
produced by the framework. The tester or the user can
open the file and observe the test cases that are passed
Fig. 2. REST API test automation framework process flow. and failed. The result file also contains an additional field
with response time of each test case that is time taken by
captured in the result file. The Table III shows the sample the API to respond for a particular REST request (test)
expected values for a single test case. The framework will which serves as a verification for performance testing. The
read and use these values to validate with the actual val- Figure 3 shows the pictorial representation of captured
ues by passing these values to the test scripts created or response time for each test.

Table II. Sample result generated by the framework. 6. CONCLUSION


Actual error Actual response Thus the manual regression testing is automated to
Actual record code code Result increase efficiency and to reduce manual testing time. The
{ 103 401 Pass process is automated with the help of a designed frame-
“errorCode”: 103”, work, which acts as a core for the entire process to com-
errorMessage”: “Invalid plete. The framework is optimized to make the automation
credentials” process simple. At the end of automation process the
}
framework produces test results which acts as a detailed

456 J. Comput. Theor. Nanosci. 16, 453–457, 2019


Venkatraj et al. Development of Test Automation Framework for REST API Testing

test report for the user to identify and analyze the failed wishes to store the result file. A descriptive document can
test cases. Since the test report is generated in a well- be created for the validation on what a particular valida-
known excel format, it is simple and easy to interpret and tion function validates and what are all the parameters it
presented in a tabular format to the user. Since there can expects, so that the user or the tester can refer the doc-
occur changes in test data and increase in API tests, it can ument while preparing the input test data file and give
be simply done by updating or modifying the input test respective validation it should perform. The framework
data. Thus increases the maintainability. The framework currently handles only JSON response, it can be made to
follows a structured procedure and a flow to run the test handle XML response also in the future to make it more
automation as shown in Figure 2. Any modification in the generic.
test data and the expected result can be made directly in
the input test data excel file. This proposed framework per-
forms automation without any manual intervention and at
References
1. Asha K.R. and Shwetha, D.J., 2015. API Testing: Picking the Right
the end produces a result file for error and bug detection. Strategy. Pacific Northwest Software Quality Conference, p.1–20.
This test automation framework becomes very useful dur- 2. Sunil L. Bangare, Seema Borse, Pallavi S. Bangare and Shi-
ing regression testing where the already tested REST APIs tal Nandedkar, 2012. Automated API testing approach. Interna-
need to be tested again. The framework can be enhanced tional Journal of Engineering Science and Technology (IJEST), 4,
by building GUI, which acts as a front end, where the pp.673–676.
3. http://hc.apache.org/httpcomponents-client-4.2.x/httpclient/apidocs/index
testers or the user can able to interact with the frame- .html.
work easily by supplying the directory path of the created 4. https://www.tutorialspoint.com/groovy/index.htm.
test data file and the path in which the tester or the user 5. https://support.smartbear.com/readyapi/docs/soapui/tutorial/index.html.

Received: 30 August 2018. Accepted: 17 September 2018.

RESEARCH ARTICLE

J. Comput. Theor. Nanosci. 16, 453–457, 2019 457

View publication stats

You might also like