DEV Community

API Testing with Katalon Studio

What is Katalon Studio?
Katalon Studio is an easy-to-use automation tool for testing APIs, web, and mobile applications. It helps both beginners and experts perform tests quickly.

Setting Up API Test in Katalon Studio

  • Download and Install Katalon Studio: Get it from Katalon.
  • Create a New Project: Open Katalon, create a new API project.

Example 1: Simple GET Request

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

def response = WS.sendRequest(findTestObject('API Requests/GetPostsRequest'))
WS.verifyResponseStatusCode(response, 200)
WS.verifyElementPropertyValue(response, 'title', 'sunt aut facere repellat')

Enter fullscreen mode Exit fullscreen mode
  • This tests if the API returns status 200 and checks the title property.

Example 2: Simple POST Request

{
  "title": "foo",
  "body": "bar",
  "userId": 1
}

Enter fullscreen mode Exit fullscreen mode
  • Send and Validate:
def response = WS.sendRequest(findTestObject('API Requests/PostCreateRequest'))
WS.verifyResponseStatusCode(response, 201)
WS.verifyElementPropertyValue(response, 'title', 'foo')

Enter fullscreen mode Exit fullscreen mode

Conclusion
Katalon Studio simplifies API testing by providing an intuitive interface. With just a few steps, you can automate API requests, validate responses, and ensure your application integrates properly.

Top comments (0)