API Automation testing

Hi,
Can you please share the steps to automate testing for API

Thanks
Gaurav

Gaurav said:

Hi,
Can you please share the steps to automate testing for API

Thanks
Gaurav

There are couple of tutorials out there to help you:
https://docs.katalon.com/display/KD/Web+Services

Hi,
Thanks for information.
Can you please help me to find out a way how i can pass the response of one API to other API call. Eg. there are 5 APIā€™s i have and to complete the booking process all the 5 API needā€™s to call and the response of 1 API will be the input for the next one. How to handle such a case.

Gaurav,
Each API call is a step in a Testcase, so we can add multi steps to handle sequence of API calls. For each API call, we can catch the response and get the neccessary information which can be easily passed to the next API call. For examples:

At manual mode, at step 1, we send a request and got the response in ā€˜responseā€™ variable.

At script mode, we can extract information from the response and use it in the next API call

ResponseObject response = WS.sendRequest(findTestObject('API - Search/Search - Bug'))
def jsonSlurper = new JsonSlurper()
def res = jsonSlurper.parseText(response.getResponseText())
println(res.issues[0].id)
WS.verifyResponseStatusCode(response, 200)
WS.verifyElementPropertyValue(response, 'issues[0].fields.project.key', 'KTP')
assertThat(response.getStatusCode()).isEqualTo(200)

image.png

1 Like

_Rest-Assured is a Java based library that is used to test RESTful Web Services. This library behaves like a headless Client to access REST web services. We can create highly customize-able HTTP Requests to send to the Restful server. This enables us to test wide variety of Request combinations and in turn test different combinations of core business logic.__Rest-Assured is a Java based library that is used to test RESTful Web Services.

http://www.traininginrajajinagar.in/devops-training-in-rajajinagar
_

suryajothika said:

_Rest-Assured is a Java based library that is used to test RESTful Web Services. This library behaves like a headless Client to access REST web services. We can create highly customize-able HTTP Requests to send to the Restful server. This enables us to test wide variety of Request combinations and in turn test different combinations of core business logic.__Rest-Assured is a Java based library that is used to test RESTful Web Services.

http://www.traininginrajajinagar.in/devops-training-in-rajajinagar
_

I am a fan of Rest-Assured (together with Hamcrest and recently is assertJ) in performing API Testing before I start with Katalon Studio. Rest-Assured might works well if you are very strong at programming language to build everything from scratch and handle everything on your own. Katalon Studio will help testers save time, effort (and cost) with the same achievement.

Firstly, Katalon Studio supports any external java libraries. In other words, you have the freedom to use Rest-Assured inside Katalon Studio and leverage all powerful features on Data-driven, assertion, integrating with UI testing, etc (all these things will cost a Tester a year to build on their own).

Secondly, Katalon Studio is not only support functional testing, it is gonna be non-functional testing.

Im using rest-assured 3.2.0 in Katalon. I referenced the jar using extranl properties in the project settings. However, with the following imports I have a problem with hamcrest:

import static io.restassured.RestAssured.*
import static io.restassured.matcher.RestAssuredMatchers.*
import static org.hamcrest.Matchers.*

It initially complained about not being able to fine hamcrest libraries and then after I referenced hamcrest 1.3 in project settings I get the following err:

java.lang.SecurityException: class ā€œorg.hamcrest.Matchersā€'s signer information does not match signer information of other classes in the same package
at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:131)
at io.restassured.internal.ValidatableResponseOptionsImpl.statusCode(ValidatableResponseOptionsImpl.java:119)
at io.restassured.response.ValidatableResponseOptions$statusCode.call(Unknown Source)
at gateway.CommonGatewaySteps.givenPaymentGatewayisAvailable(GatewaySteps.groovy:111)
at āœ½.The Payment Gateway is available(C:/Users/bmcleod/Katalon Studio/TEst.prj/Include/features/BDD Cucumber Tests/Web API Tests/Payment Instrument Test.feature:8)

How do I resolve?

@brian.mcleod
Hi Brian,
Not sure if you have already resolved this issue or it is too late for you but we were able to resolve this issue by deleting version of hamcrest library that comes with Katalon Studio (as Eclipse plugin) and replacing it with the one we need (put in the same location with the same name as the one deleted)

Location of the file to replace is at $KATALON_STUDIO_FOLDER\plugins\org.hamcrest.core_1.3.0.v201303031735.jar

2 Likes