Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Sample Project Overview 
3.
Sample API tests project
3.1.
Sample API project components
3.1.1.
Profiles
3.1.2.
RESTful requests
3.1.3.
Custom keywords
3.1.4.
Test cases
3.1.5.
Data Files
3.1.6.
Test suites
4.
Execute selected test cases or test suites
5.
Frequently Asked Questions
5.1.
What characteristics does Katalon Studio have?
5.2.
Which is best Selenium or Katalon?
5.3.
Which framework does Katalon Studio employ?
6.
Conclusion
Last Updated: Mar 27, 2024

Sample API tests project in Katalon

Author Shivani Singh
0 upvote
OG Image

Introduction

Teams of various sizes and testing maturity levels can benefit from the testing solutions offered by the Katalon platform. One of the well-known tools for automated testing is Katalon Studio. As more and more testing engineers choose Katalon, it merits discussion alongside Selenium, Ranorex, TestComplete, and Apache JMeter. The platform enables the creation of analytical reports, test recording, and the execution of automated tests for Windows desktop, iOS, Android mobile apps, Web interfaces, APIs, and desktop and desktop Windows apps. A suite of tools from Katalon may assist small teams in the beginning stages of their automation journeys and scale up to large international corporations looking to use AI/ML to fine-tune and optimize their quality process.

Katalon platform provides various tools like Katalon Studio, Katalon Studio Enterprise, Katalon Runtime Engine, Katalon TestCloud, Katalon TestOps, and Katalon Recorder. 

Here in this blog, we will see some of the sample Katalon projects to get familiar with the Katalon Studio. And will also see how to create some basic projects in Katalon Studio. So what are we waiting for? Let us get started. 

Sample Project Overview 

What if you get a sample project before working on any final project? Isn’t it will be easy to deal with it? Katalon has done the same. It has provided some sample projects to learn about the Katalon Studio. It has created many sample projects for each testing type. To open those sample projects, you need Katalon Studio. After installing Katalon Studio, select a sample project by going to File/New Sample Projects. Here we will see some of the primary projects given by Katalon.

  • Website testing (Healthcare sample)
  • Data-driven testing for web user interfaces (Shopping Cart sample)
  • Testing of APIs
  • Mobile testing, with example projects for Android and iOS
  • Testing of BDD (Cucumber)
Sample Project Overview

Sample API tests project

In this blog section, we will see the Sample API tests project provided by Katalon. To open the sample Sample API tests project, go to File > New Sample Project > Sample API tests project.

You can also download all the sample projects in the Katalon GitHub repository.

Sample API tests project

Sample API project components

Profiles

Go to Profiles > default and click the Execution Profile link. All global variables can be created and saved in the execution profile. They apply to all test cases in your project. Katalon produces three global variables in this example project: baseURL, successCode, and globalid.

Profiles

RESTful requests

In this project, we generated two sample RESTful requests: a POST request and a GET request. Go to the Object Repository folder in the Test Explorer window to retrieve the sample RESTful requests. 

RESTful requests
  • The POST a new user object: In this sample POST object, the following details are provided:
  • Request method: With Katalon, you can select the GET, POST, PUT, DELETE, PATCH, HEAD, CONNECT, OPTIONS, and TRACE methods. To be a legitimate request, the method must match the API endpoint.
  • Request URL: The requested URL notifies the web server of which API is being tested and the request method. Any incompatibility between the process and the URL results in a runtime exception for an invalid request or an incorrect data response.
  • Authorization: A vital component of an API is an authorization. It is utilized to obtain accurate info with permission (unless the data is public).
  • HTTP Header: The header data required for transmitting the RESTful request can be configured. The HTTP Body tab's input automatically creates the Content-Type header by default.
  • HTTP Body: Text, x-www-form-urlencoded, form-data, and file is the body data formats that Katalon Studio supports.
  • Verification: The Verification tab of the web service object in Katalon Studio enables you to construct verification scripts easily.
  • Variables: We declare variables in the Variables tab to pass their values to the POST request.
  • The Response tab: The automatic response presentation in JSON, XML, HTML, and JavaScript tidy formats.
  • The GET user by id object: In this GET object sample, we include the following details:
  • Request method: In the example GET request, the userID is used to access user information.
  • Request URL: We put the placeholder $variable name> at the end of the API endpoint to provide the id variable to the GET API.
  • Variables: In the Variables tab, we define the value for the id variable.
  • Authorization, HTTP Header, and HTTP Body: For this GET request, we don't include any license, HTTP header, or HTTP body information.

Custom keywords

In this example project, Katalon generates two unique keywords. Go to Keywords > sample > Common. groovy in the Test Explorer tab to view the custom keywords.

Custom keywords
  • sample.Common.createNewUser: This keyword is employed to create an account, send a POST request to the server, and have it respond with a userID. Run verification snippets from the POST request's Verification tab. Take the response and extract the new user ID. The five criteria are age, username, password, gender, and expected status.
  • sample.Common.findUserById: The GET request to access user information using the userID is sent using this keyword. Run verification snippets from the GET request's Verification tab. Id, age, username, password, gender, and expectedStatus are the required inputs.

Test cases

Go to the Test Cases folder in the Test Explorer panel to access the example test cases for this project.

There are two test cases with various objectives:

  1. The test case to create a new user is to do just that. We apply the sample in the test scenario. Common. utilize the keyword to create an account, and send the user's details, including username, password, gender, and age, to the server.
  2. In the Find user by ID test case, user information is retrieved using a userID.

Data Files

Go to Data Files > ListUser in the Test Explorer panel to view the data files in this sample project.

Alternatively, you can open the desired file by going to "your-project-folder" Data Files:

  1. ListUser.dat is the ListUser.xlsx file's.dat file.
  2. The user data can be found in the spreadsheet file ListUser.xlsx.

Test suites

The example test suite illustrates data-driven testing for web services. Go to Test Suite > web-service-tests - All Test Cases in the Test Explorer window to view a sample test suite. The test cases Find user by ID and Create a new user are included in this test suite. We link the ListUser data file to the Create a new user test case. Create a new user test case, then click Show Data Binding to see the data binding section.

Execute selected test cases or test suites

In the example project, to run a test case or test suite:

1. Decide the test case or test set you want to run.

2. Either click Run or use Ctrl + Shift + A (Cmd + Shift + A on a macOS).

3. Check the Log Viewer tab to see the test result.

Frequently Asked Questions

What characteristics does Katalon Studio have?

Simple Deployment, Quick & Easy Set-up, Faster & Weightier Outcomes, Flexible Modes, Easy Usage, Cross-Browser Application, etc., are some of Katalon Studio's key features.

Which is best Selenium or Katalon?

In general, Selenium moves more quickly than Katalon studio. The reason is that because Katalon is built on Java and uses the scripting language Groovy, more test objects, libraries, etc., must be loaded. If the test is particularly long, the difference in speed and performance will be apparent.

Which framework does Katalon Studio employ?

Groovy, a Java-based language used by Katalon Studio, requires loading numerous libraries to parse test data, test objects, and logging.

Conclusion

To conclude this blog, we have discussed a sample project by Katalon. Then we discussed the Sample API tests project, its profile, RESTful requests, customs keywords, test cases, data files, and test suites.  

For more content, Refer to our guided paths on Coding Ninjas Studio to upskill yourself. 

Do upvote our blogs if you find them helpful and engaging!

Happy Learning!

Thankyou

Live masterclass