API testing (or web service testing for a web application) is a quick and effective way to validate an application’s logic without having to examine the GUI of the application under test.
In today’s DevOps and Agile age of software development, API testing is the preferred test automation method as it can cope with short release cycles, and the frequently changed presentation layer without breaking the test outputs.
Make sure you already downloaded Katalon Studio at www.katalon.com
Start API testing with Katalon Studio
Step 1: Create a new project
To start a new project, select File > New > Project then enter a project name and its location.
After selecting OK, you can find the project’s folder structure in the Test Explorer panel. The Test Explorer panel will unify and store all of your test resources.
The four main folder categories are:
- Test Case: All test scenarios are stored and grouped in this folder. Each test case is designed for a test scenario with multiple test steps. A test case can be executed individually with a specified execution profile.
- Object Repository: All the Web service endpoints and/or requests, including URL, header, content, and authentication are stored in this folder. In the Object Repository category, Web service test objects are integrated into a folder system for ease of management.
- Test Suites: All test suites — collections of test cases verifying a specific target — are stored in this folder. Plus, test reports are generated at the test suite level. Test cases in the test suite level can be executed with the data-driven approach.
- Test Suite Collection: A collection of test suites that verify a larger target with specific Test environments specified.
Step 2: Create a new RESTful endpoint at Object Repository
As all Web service endpoints are stored in Object Repository, go to Object Repository > New > Web Service Request to create a new request.
You are required to choose between a RESTful and SOAP request in the Request Type list in this step. The URL box is not required, and you can update it later in the next step.
Click OK to move on to the next details input step.
Items needed to be specified for a RESTful request:
(1) Request Method
Choose one among the following methods for your request test: GET, POST, PUT, DELETE. Note that only the method that matches the URL is a valid request. If the items mismatch, there will be invalid request exceptions at runtime or wrong data response.
(2) Request URL
Request URL is used to specify which API is utilized in the web server under test. If the method and URL mismatch, there will be invalid request exceptions at runtime or wrong data response.
As an essential step of API testing, authorization ensures the data input is proper. Katalon Studio offers common authentication methods, namely Basic, OAuth 1.0, OAuth 2.0.
For example, in the Basic authentication method, you will have to input your username and password.
Make sure to click Update to HTTP Header so that the authentication can be applied to the HTTP Header.
Verification is to confirm that the response will contain the expected information based on the defined assertion. The verification tab of a request resembles the Script tab of a test case.
Specifically, you can write custom scripts with built-in keywords or Groovy/Java scripts to verify the response data. Apart from the built-in keywords, Katalon Studio provides built-in snippets, allowing you to generate assertions within a single click.
The panel on the right is the automated response formatted for ease of use. Also, in this panel, you can find your verification results in the Verification Log tab. To have the verification script included when sending the request, you need to choose the Test Request and Verify option from the execution button.
The Verification script is useful in getting quick feedback on the request status rather than the actual test. More assertions can be added to the test case level later in the next step.
Katalon Studio supports variables for both RESTful and SOAP Web Service Test Objects. Variables play a key role in increasing robustness and dynamic for API testing with the data-driven approach.
Using variables in an object helps you to gain more control of the objects and meet all of the testing requirements. In Katalon Studio, every part of the request can be parameterized. Specifically, dynamic data can be used for: URL, Authentication, HTTP Header, and HTTP Body to maximize the capability of data-driven testing.
Step 3: Create a new test case with an existing request
The request at Object Repository is helpful for fast testing, plus you can add the request verification at the test case level to improve management and report.
Step 4: Add an existing request to a test case
By leveraging Web service built-in keywords, you can simplify the process of inserting, sending, verifying, and making your requests to become part of a bigger testing flow.
Here is how to call a request in the verification step with test cases:
Your test case can be executed as a normal test case in Katalon Studio. Each verification step can be viewed in the Log Viewer.
Step 5: Add a test case to the test suite
To add a test case to a test suite, use the drag-and-drop feature or the Add test case tool.
You can use either the drag-and-drop feature or the Add test case tool to add a test case to a test suite.
The test suite can be executed after the test case is added by clicking the Run button (without selecting a browser to run as in Web UI testing).
API testing is one of the most crucial skills for any tester as it helps save time and effort spent on testing their product. API testing increases the test coverage of your test cases, thus speed up the release process for your bottom line.
A proper test automation tool is also a key factor for a successful API test project. Offering a productive IDE for API automation, Katalon Studio is placed among the leading end-to-end testing tools covering web, mobile, API, and desktop testing.
The latest Katalon Studio version can be downloaded at www.katalon.com.
- ‹ Katalon Studio Introduction - Your Best Selenium Alternative Solution
- Beginners guide to Web testing with Katalon Studio ›