Rest API testing using Katalon Studio

Hello friends, in this tutorial, we are going to learn Restful web service automation using Katalon Studio. Katalon with its new and improved features as well as interface (refer to Katalon version 5.4 and above) helps in seemless automation of Rest and SOAP web services. If you are new to Katalon Studio, do check our tutorial on Setup and installation of Katalon studio before continuing with this tutorial. Now, let's see how to do automation testing of Rest APIs using Katalon.
For this demo, we will be using a public dummy REST API - RestApiExample.

Steps for REST API testing using Katalon-

  1. Create a project-
    Go to File menu -> New -> Project. Enter project name and select its location. Also, we can optionally provide a project's description.
    katalon studio project
  2. On clicking 'OK', we will see a 'Test Explorer' pane on the left hand side.
  3. Now, right click on "Object Repository" directory icon and click on 'New' -> "Web Service Request"
    object repository katalon
  4. Name the web service request e.g. 'GetEmployeeRequest', set the type of API request (e.g. RESTful), provide the API URL (we can also leave it blank in this step) and click 'OK'.
  5. On the right hand side, we will see below details for our request.
    api testing ArtofTesting katalon studio
  6. Now, we can set the fields with the API specific details like-
    • The HTTP method of the API e.g. GET
    • The API URL-
      http://dummy.restapiexample.com/api/v1/employees
    • Based on the API, we can similarly set the 'Authorization', 'HTTP Header' and 'HTTP Body' fields.
  7. Now, we can hit the request by clicking the play icon next to the URL field. The response of the same will get displayed in the Response section along with the 'Status'. api testing using katalon studio
  8. Our API request is set now, next we need to create a test case under the 'Test Cases' directory. For this, go to 'Test Cases' -> 'New' -> 'Test Case'. Name the test case e.g. 'GetEmployeeDataTest' and click 'OK'.
  9. On the right pane, we need to add "Web Service Keywords" in order to hit and verify the API response.
    web service keywords katalon studio
  10. In this demo, we will add 3 web service keywords-
    • Send Request - Send request keyword is used for hitting the API that we had set under the 'Object Repository' directory. The 'Object' field will be the name of the API i.e. 'GetEmployeeDataTest'. We also, need to save the output to a variable by setting the 'Output' field with a variable name. The same variable will be used in subsequent keywords.
      web service send request
    • Verify Response Status Code - This keyword is used for verifying the response status on hitting the API. Set the input field as below-
      verify response code
    • Contains String - This keyword is used to check if a string appears in the response of the API. Set the input field as below-
      contains string
  11. Once done, the right pane will look like this-
    api testing katalon
  12. Now, we just need to hit the play icon to run the individual test case. Alternatively, we can also add multiple test cases to a 'Test Suite' and run the whole test suite in one go.

This concludes our tutorial on API testing using Katalon Studio. Do check our other tutorials on Katalon Studio to further enhance the script.