Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
API Testing
3.
Creation of new project and setting up API automation test
3.1.
Step 1: Create a new project
3.2.
Step 2: Create the first API test
3.3.
Step 3: Create a new RESTful endpoint at Object Repository
3.4.
Step 4: Create a new test case with an existing request
3.5.
Step 5: Add an existing request to a test case
3.6.
Step 6: Add the test case to the test suite
4.
Create Custom API/Web Service Methods
5.
Frequently Asked Questions
5.1.
What is Katalon Studio used for?
5.2.
Is Katalon Studio better than Selenium?
5.3.
Is Katalon Studio still free?
5.4.
What language does Katalon use?
5.5.
Is Katalon suitable for automation?
6.
Conclusion
Last Updated: Mar 27, 2024

Create your first API test with Katalon Studio

Author Aditi
0 upvote

Introduction

Have you ever worked with any automated testing software tools? Have you ever created your API test?

This article is focused on one of these automated testing software tools, i.e., Katalon Studio. Katalon Studio is built on the open-source Selenium and Appium automation frameworks. It has a specialized IDE interface for API, mobile, web, and desktop application testing. 

Let's dive into the article if you know more about Katalon Studio.

Create your first API test

API Testing

API stands for Application Programming Interface. It is a way by which two or more computers communicate with each other. API testing has become crucial in software testing. API testing has increased its popularity, according to Google Trends, in five years. This indicates that it is more prevalent to apply API testing. Testing web services or API is not only the work of developers. It has become a common practice for outsourcing teams who work independently for their products.

This tutorial will give you step-by-step guidance for creating your first API/Web service test using Katalon Studio. It will be from scratch. So, beginners can also learn and create their API test.

Creation of new project and setting up API automation test

Step 1: Create a new project

  • Go to File -> New -> Project
  • Enter a project name to start a new project and its location.
  • When the project is created, you will see a folder structure. It will be in the Tests Explorer. This folder system keeps all the test resources. It is also where we start our first API test.

Step 2: Create the first API test

Let's know about the format before creating the first API testing. It will be used for setting up a testing project.

  • Object Repository: It is a place that stores all the endpoints of Web service. It also stores the Request method, Header, Content, URL, and Authentication. Web service test objects are integrated by a folder system in the Object Repository. It is for better management.
  • Test Cases: It stores all test scenarios. It is grouped by a folder system. Each test case has some steps of test scenario illustration. Execution of individual test cases is possible with a specified execution profile.
  • Test Suites: It is where all test suites are stored. It is a collection of test cases. These cases verify a specific target. Test cases can be executed in a data-driven approach.
  • Test Suite Collection: It is the collection of Test suits. Suits are those which verify a larger target. At this level, test suites have specific Test environments specified.

Step 3: Create a new RESTful endpoint at Object Repository

  • Go to Object Repository -> New -> Web Service Request
  • Web service endpoints are stored by Katalon Studio. It is for testing at the Object Repository. It is similar to Test Object in the UI Test. You can create a SOAP  or a RESTful request. It is present in the Create New Web Service Request dialog. You need to specify it in the Request type field. URL is not required in contrast to the Request type, which is required. You can set the URL value later.
  • Click OK. We are now adding more information to the first RESTful test.

 

Some essential concepts need to know before testing a RESTful request:

  1. Request method: We can choose one of the following methods: GET, POST, PUT, or DELETE. They need to match the URL. It is to have a valid request.
  2. Request URL: The requested URL informs the web server which API is being tested. An incorrect data response or an invalid request exception at runtime will result from any method and URL mismatch. 
  3. Authorization: It is an essential part of API. It is used for getting data under permission. The basic method Katalon Studio supports requires a username and password. Click on  Update to HTTP Header. It will apply authentication to HTTP Header.
  4. Verification: The assertion is defined during verification. It is to make sure the response contains the data you expect it to. You can create custom Java/Groovy scripts using built-in keywords to check the response data. Katalon Studio now supports built-in snippets. It allows you to easily and quickly create assertions. It is beneficial for testers dealing with JSON data. To include the verification script, choose the Test Request and Verify options while sending requests from the execution button. It helps in quick feedback on the request status. 
  5. Variables: They are responsible for making API testing dynamic and robust with the data-driven approach. Each Request part can be parameterized in Katalon Studio. Dynamic data can be used for
    • URL, 
    • Authentication, 
    • HTTP Header, and
    • HTTP Body to increase data-driven testing capability.
  6. Formatter: It displays the response automatically in a neat format. The format can be   XML, HTML, JSON, and JavaScript. It helps in a quick review of response status.

Step 4: Create a new test case with an existing request

Requesting at the Object Repository is beneficial for fast testing. We can also add the request verification. It can be added at the test case level. It helps in better reporting and managing.

Step 5: Add an existing request to a test case

A request can be added to a test case with the help of built-in keywords for Web services. Various keywords can be used to check, send and include the request in a larger testing flow. 

The test case given below shows how we can call the request while using test case verification steps:

Add an existing request to a test case

                                                                        Credit: docs.katalon.com/

In Katalon Studio, the test case can be run like any other test case. The log allows you to view each step of the verification process.

Step 6: Add the test case to the test suite

We can add test cases in two ways to a test suite:

  • drag-and-drop feature
  • the Add test case tool

We can execute the test suite by clicking the Run button. It is when the browser is not selected as in UI testing. It happens when all test cases are added to the test suite. 

Create Custom API/Web Service Methods

You can also create Custom API or Web Service Methods using Katalon Studio. Keeping this in mind that you can only use the feature of creating custom API or WebService Models in the Katalon Studio for Enterprise Users edition.

Let’s move on to creating a Custom API or Web Service Model in Katalon Studio. You can create Custom API or Web Service Method using the following steps:

  1. You can create Custom API/Web Service Methods to expand RESTful Web Service Testing capabilities. 
  2. Start by clicking on the Project.
  3. Next, Click on the Settings options.
  4. Now, click on the Test Design in the Project Information.
  5. Next, click on Web Service. This will show the option Custom Method
  6. Click on Custom Method
  7. Now, a Dialog box will appear with the heading New Method.
  8. You can type the Method and the Description of the Methods as per the requirements.

Custom API methods are handled by Katalon studio above all the default supported methods set.

Create Custom API/Web Service Methods

 

Frequently Asked Questions

What is Katalon Studio used for?

Katalon is used to create and reuse automated test scripts for UI without coding. It allows running automated tests of UI elements. It can be launched on Microsoft Windows, macOS, and Linux.

Is Katalon Studio better than Selenium?

Selenium is faster than Katalon studio. The reason behind it is the scripting language. Katalon uses Groovy, which is built on Java. So it has to load more libraries, test objects, etc. The difference in performance and speed will be noticeable if the test is very long.

Is Katalon Studio still free?

The free plan of Katalan Studio is suitable for individuals and small teams. The Premium plan is best for large teams or SMBs who need different test results and have production-grade testing workloads. 

What language does Katalon use?

Katalon Studio uses Groovy, a language built on top of Java. It has to load many libraries for parsing test data, objects, and logging.

Is Katalon suitable for automation?

Katalon is a good tool for test automation, both for APIs and Web Pages. 

Conclusion

This complete article has helped us to learn about all the concepts and steps for creating the first API test. We need to learn the implementation of API testing. It will help you to achieve amazing results. It will also save you time and effort. In this article, we have discussed the steps to create the first API Testing in Katalon Studio. We have also explained how you can create custom API/Web Service methods.

We hope this blog has helped you enhance your API Testing knowledge. Check out our articles to learn more about the introduction to API and its usageWeb API introduction, and real-world API. Practice makes a man perfect. To practice and improve yourself in the interview, you can check out Top 100 SQL problemsInterview experienceCoding interview questions, and the Ultimate guide path for interviews.

Do upvote our blog to help other ninjas grow. Happy Coding!

thank you
Live masterclass