Table of contents
1.
Introduction
2.
Schema Compliance Testing in Katalon Studio
2.1.
What is a Schema?
2.2.
Validating against Schema in a Web Service Request
2.3.
Validating against Schema in Test Cases
3.
Frequently Asked Questions
3.1.
Which framework do we use in Katalon Studio?
3.2.
Define Unit Testing.
3.3.
Do you have any idea about Katalium?
3.4.
Describe Katalon Recorder.
4.
Conclusion
Last Updated: Mar 27, 2024
Medium

Schema compliance testing in Katalon Studio

Author Rupal Saluja
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

We all must agree that testing is integral to developing web applications. It informs us whether the task is performing as per our expectations or not before it is launched.

Katalon, a platform for Automation Testing, is used to test web applications, APIs, and mobile and desktop applications. It is a powerful automation tool designed to generate and reuse automated test scripts for the User Interface without any need to code.

logo of Katalon

In detail, this article will discuss various aspects of Schema Compliance Testing in Katalon Studio. So, without further ado, let’s start.

Schema Compliance Testing in Katalon Studio

Schema Compliance Testing in Katalon Studio tests whether every request or response follows the consequent schema definition. In the previous blog, API Testing in Katalon, you have learned the necessity of accurate schema under understanding applications under test (AUT) module. The schema of any application plays an important role in validating requests and responses.

notion of schema

Testing schemas is a straightforward and successful approach to checking whether your APIs are working up to your expectations.

What is a Schema?

A Schema is like a skeleton. It is a document that describes the structure of any instance or application. This document is used to check whether that instance or application matches the required number of criteria or not.

An instance is a part of the application being checked or verified. We test instances when we do not want to test the complete application.

Nowadays, Schema Compliance Testing has become immensely popular. This is because it is the easiest way to eliminate frequent interface errors. The term ‘Contract Testing’ is used to describe large-scale testing projects given as contracts. These contracts generally contain a huge number of JSON or XML schemas.

Use the diagram below to understand the importance of Schema in API Testing.

flowchart of api testing

Validating against Schema in a Web Service Request

This module discusses validating against Schema in a Web Service Request as a part of Schema Compliance Testing in Katalon Studio. Use the steps below to complete the process successfully.

1. Open the Test Explorer Tab from the home screen of Katalon Studio.

2. Select the Object Repository option and create a new Web Service Request. 

path for web service request

3. A screen appears displaying the parameters for a new Web Service Request. From the tabs given in the Object Editor View, select the Validation Tab.

first screen for adding validation

4. You can see two options there- Add and Remove. To add a new Validation, click on Add.

5. You will be asked to input the following information given in the table.

Option

Description

Name It is the name of the new validation.
Target There can be two targets for any validation- Response or Request.
Schema Type There are four options available in schema type parameter- JSON, XML, GraphQL, Auto Detect.
Input Type There are three options available in input type parameter- URL, File, Auto Detect.
Location/Value Here, you have to input an URL or file path leading to schema. If Input Type is File, select Browse on the Location/Value cell to get the appropriate schema file location.
Validate This parameter selects the schema to validated against in Web Testing.

6. When you are done with your inputs, Click on Save.

7. Now, open the dropdown menu of the Test and Request option and click on Test Request and Verify.

8. Refer to the Response section. Switch to the Validation Log Tab to see Validation Results on your screen.

PASSED: This means all the requests and responses have passed the validation.

FAILED: This means at least, or more requests or responses did not pass the validation.

screen for validation results

In case of failed response or request, select each line of the Result Table to view the problem details. This will open a dialog displaying a list of issues, if any.

You have completed validating against schema in a web service request.

Validating against Schema in Test Cases

This module discusses validating against Schema in Test Cases as a part of Schema Compliance Testing in Katalon Studio. There are three keywords used in the process.

  • Validate GraphQL request against a GraphQL Schema
  • Validate an XML string against a schema
  • Validate a JSON string against a schema

 

Use the steps below to complete the process successfully.

1. Execute your scripted test case in the Log Viewer. Refer to the test case below in script mode for a better understanding.

result = Test.sendRequest(findTestObject('XML'))
String xml = '''<?xml version="1.0" encoding="utf-8"?>
<List>
   <item>
       <id>4</id>
       <username>Johnson & Johnson</username>
       <password>88170</password>
       <gender>MALE</gender>
       <age>56</age>
       <avatar/>
   </item>
</List>'''
String xmlFile = FileUtils.readFileToString(new File("example/xml/person.xml"), "utf-16");
Test.validateXmlAgainstSchema(result, "example/xml/person.xsd");
Test.validateXmlAgainstSchema(xml, "example/xml/person.xsd");
Test.validateXmlAgainstSchema(xmlFile, "http://localhost:8080/api/users/xsd", FailureHandling.STOP_ON_FAILURE);


2. You will see the outcomes of the validation tests you added to your script. The most common outcomes are listed below.

  • Validation passed
validation passed screen
  • Validation failed
validation failed screen
  • Send request failure over root cause
send request failure over root cause

The above-given types can be used for several uses. The most prominent ones are listed below.

  • JSON Schema: Validation of RESTful request and response body content.
  • XML Schema: Validation of RESTful and SOAP request and response body content.
  • GraphQL Schema: Validation of GraphQL request body content.

Frequently Asked Questions

Which framework do we use in Katalon Studio?

We use the Groovy framework in Katalon Studio. Groovy is a Java-based framework that requires the loading of several libraries. These libraries are used to parse test data, objects, and logging.

Define Unit Testing.

A unit is the smallest testable component of an application. These components are examined separately and individually for the proper execution of software.

Do you have any idea about Katalium?

The name Katalium is made up of two terms- Katalon and Selenium. Katalium is a framework that facilitates designing TestNG and Selenium-based test automation projects.

Describe Katalon Recorder.

Katalon Recorder is an extension available for Firefox, Edge, and Chrome. It is one of the most popular, straightforward, and highly user-friendly Record and Playback Extensions.

Conclusion

Overall, we understood several aspects of Schema Compliance Testing in Katalon Studio. This includes 

We hope the above discussion helped you understand Schema Compliance Testing in Katalon Studio and can be used for future reference whenever needed. To learn more about Katalon Studio and its components, you can refer to blogs on Installing Katalon StudioLooping Statements in Katalon StudioKatalon Studio vs ACCELQKatalon Studio vs Ready API, and Keyboard Shortcuts in Katalon Studio.

Visit our website to read more such blogs. Make sure you enroll in our courses, take mock tests, solve problems, and interview puzzles. Also, you can pay attention to interview stuff- interview experiences and an interview bundle for placement preparations. Do upvote our blog to help fellow ninjas grow.

Happy Coding!

Live masterclass