REST API Services Testing using loadrunner

REST API Services Testing using loadrunner,rest api services uses web http/html protocol while creating REST API Services scripts using virtual user generator,which is a loadrunner component.Most of the companies are using REST API services in order provide better security in customer data,fast execution for communication between
multiple applications.

Please read Complete Loadrunner Tutorial

[embed]https://youtu.be/jYlUPEC1WfE[/embed]

REST API Services Testing using loadrunner


In this post we will create REST API Services script in Virtual User Generator i.e VUGen,Please follow below steps to create script for REST API services using VUgen.

Steps:


1.REST API URL
2.Which Protocol should use
3.What is the input parameters
4.What is the output Response
5.Content- Type
6.Method - GET,POST,DELETE etc.

Once you know all above details then it is easy to create the script with the help of below simple syntax ,plesae use below syntax for all rest api services for load testing.
web_custom_request("Card_validation",
"URL=http://ipaddress:portno/cardApi/api1/card/linkcard",
"Method=POST",
"Resource=0",
"EncType=application/json",
"Mode=HTTP",
"Body="Body={\"cardNo\":\"9898989898989898\",\"cardType\":\"CreditCard\",\"MobileNo\":\"1111111111\"}",
LAST);

CODE Explanation:


As you see above code i have used web_custom_request() function which is allow users to create custom HTTP request with any useful method(POST,GET,DELETE etc)

1.Card_validation : Request Name

List of Resources:


URL
Method
Resource
EncType
Mode
Body

Method=POST:


As based on above resources we will create REST API Services scripting as you see "Method=POST" which is posting the values to database,in case you want to get the details from the database then you can use "Method=GET".

EncType=application/json:


As i have used application/json because content-Type of REST API service is developed with Media Type,as REST API Services has below Media Types,those are

1.application/json
2.application/xml
3.text/xml
4.multipart/form-data
5.multipart/mixed

Most of the REST API services are developed with application/json,application/xml and text/xml media types,this one provided by developer.

Mode=HTTP:


As i mention in first paragraph REST API service is developed with HTTP protocol for data transfering to multiple systems.While creating the REST API script you need to select
Web-HTTP/HTML protocol.

Body:


Body resource which contains input request parameters as i written in above script.The main rest api input request is as below
{
"cardNo":"9898989898989898",
"cardType":"CreditCard",
"MobileNo":"1111111111"
}

You can write above input request into below code in order to mention in Body resource.Please check below code.
"Body={\"cardNo\":\"9898989898989898\",\"cardType\":\"CreditCard\",\"MobileNo\":\"1111111111\"}"

LAST:


LAST argument which tells a market which indicates the end of the field list.This total web_custom_request() function returns LR_FAIL(1) or LR_PASS(0) on successful and on failure of web_custom_request()
function execution.

Parameterization:


We can perform Parameterization for input parameters as we mention in Body ,Please read Correlation in loadrunner post,you will get clear idea about manual and automatic correlation for any script whether it could be a web request,rest api or Web-Services.

Thank you for reading,i hope you got good knowledge about REST API Services Testing using loadrunner,please provide your valuable comments and suggestions on this post.

No comments:

Post a Comment