Create your first API test with Katalon Studio
Introduction
API testing (or Web service testing in the context of a Web application) has become more important in software testing. The interest in API testing has been increasing over the last five years. This trend possibly indicates that the demand for applying API testing has become more prevalent. Testing API or web services is no longer performed solely by the original developer. This activity is now a common practice among outsourcing teams who independently verify and validate their products.
This tutorial demonstrates how to use Katalon Studio to create your first API/Web service test from scratch with practices.
Components in an API test project
Before creating our first API test, let's have a look at the format we use to set up a testing project.
Object repository
- Object repository is a place which stores all the Web service endpoints along with all information of request method, URL, header, content, and authentication.
- Web service test objects in object repository are integrated by a folder system for better management.
Test cases
- Test cases stores all test scenarios and is grouped by a folder system. Each test case includes a few steps illustrating a test scenario.
- We can execute a test case individually with a specified execution profile.
Test suites
- Test suites is the place where all test suites are stored. A test suite is a collection of test cases verifying a specific target.
- Test cases at the test suite level can be executed with a data-driven approach.
- Test reports are also generated at the test suite level
Test suite collection
- Test suite collection is a collection of test suites verifying a larger target.
- Test suite at test suite collection level has specific test environments specified.
RESTful endpoint in object repository
Katalon Studio stores Web service endpoint for testing at Object Repository, which is similar to Test Object in UI Test.
There are some important concepts needed to specify when testing a RESTful request:
Request method
We can choose one of these following methods for your first request test: GET, POST, PUT, DELETE. The method needs to match with the URL to have a valid request. For instance, let's assume that our first test is a public API from Jira Cloud version. We should use the GET method to receive information on an existing ticket using its ID.
Request URL
Along with the request method, request URL is used to tell the web server which API is utilized under test. Any mismatch between method and URL will lead to invalid request exception at runtime or wrong data response.
Follow redirects
The Follow redirects option allows you to control how your requests handle HTTP 3xx status code responses. This option ensures accurate test results and manages the flow of requests.
When enabled, Katalon Studio automatically follows the redirection path provided by the server, ensuring that your test reaches the final destination without additional intervention.
When disabled, the request stops at the redirection response, allowing you to manually handle and inspect the redirection URL.Note:You can enable Follow redirects by default by going to and then selecting Enable follow redirects by default.
Authorization
Authorization is an essential part of an API. It is used to get the correct data under permission (unless the data is public). Katalon Studio supports common authentication methods:
The basic method requires username and password. Don't forget to click Update to HTTP Header so that the authentication can be applied to HTTP Header.
Verification
Verification is the place where you define the assertion to ensure the response will contain the expected information.
The verification tab of a request is similar to the Script tab of a test case. In other words, you can write custom scripts with built-in keywords or Groovy/Java scripts to verify the response data. Besides built-in keywords, Katalon Studio also supports built-in snippets, which help you to generate assertions with a single click. It is useful for testers who might find it difficult to deal with parsing and to assert with JSON data format.
The right panel of the request is the response displayed in nice format automatically and the result of verification at Verification Log. To include verification script when sending the request, you need to choose the Test Request and Verify option from the execution button.
The Verification script helps you have quick feedback of the request status rather than an actual test. You can add more assertions to the test case level in the next step.
Variables
Variables make API testing more robust and dynamic with the data-driven approach. In Katalon Studio, every part of the request can be parameterized. In other words, dynamic data can be used for: URL, Authentication, HTTP Header, and HTTP Body to maximize the capability of data-driven testing. Following setup works the same with the above example:
Formatter
The response will be automatically displayed in a neat format: JSON, XML, HTML, and JavaScript. It is helpful for a quick view of the response status.
Create API tests in Katalon Studio
This section shows you how to create API tests in Katalon Studio.
Create Custom API/Web Service Methods
This feature is only available for Katalon Studio Enterprise users.
You can create Custom API/Web Service Methods to expand RESTful Web Service Testing capabilities by going to Project > Settings > Test Design > Web Service > Custom Method. Katalon handles custom API methods on top of the default set of supported methods.
Next steps
Now we finish creating our first test. In order to create tests for a real project with a practical solution, we would need to create more tests with more techniques:
- Parameterize your tests
- Apply data-driven approach
- Create custom keywords/packages
- Call tests and reuse code
- Include error handling
- View test reports after test suite execution
Conclusion
This complete tutorial helped us go through all the steps and concepts needed for users to create the first API test. In order to achieve the best outcomes and save time and effort, we have to learn how to use API testing properly. For example, we need to have an appropriate implementation of techniques and awareness of whether an API should be tested automatically or manually. Therefore, if we make enough effort and master your Katalon Studio skills, the tool will definitely help us significantly increase the quality of any target product.