API Test using katalon
API or Application Programming interface is a set of rules or protocols that enables software applications to communicate with each other to exchange data, features and functionality.
API tests focus on the functionality and integration of backend services, are faster to execute, and are independent of the frontend UI meanwhile UI tests focus on the user interface, simulate user interactions, and ensure that the application meets user expectations but are slower and more dependent on the UI’s stability. In practice, both API tests and UI tests are important for ensuring the overall quality of a software application, with each type providing valuable insights into different aspects of its functionality and usability. However, UI test must be in priority for the tester to test as method for E2E test.
So here some test cases for api test:
- To validate status code
- To validate error handling and message code
- To validate he body or http body respons
- To validate response time
In this article, there are 3 steps into basic api tester:
- Create and run testcase
- Create and run test suite
- Reporting
Lets begin the journey to create and run testcase for API Test by using Katalon Studio:
- You should install katalon Studio free in your local machine. Here’s the url for downloading: https://katalon.com/download .
- After the Katalon has been installed in your local machine, then login first (if you are already registerd, if not, please registered first).
- If the Katalon already opened, you should make the new project locally, so here’s how it looks:
4. Set type Name of project -> Chose type API web service -> chose project as ‘Blank’ -> dont forget to set location as you wish -> ok
It will preview like this:
After you finally create new project of API service, now you can try to test some API. In this article, i used free example API from internet, here is the source of free API example: https://dev.to/ritaly/the-simplest-guide-to-curl-for-rest-api-requests-35ii .
Thus, the fist step to test api, you should create new object repository. Here’s the step:
1. Right click on your mouse at object repository.
2. Object repository -> new -> web service request -> input name -> chose restful(if you are using rest API) -> ok
Now, we can create our api first, i used api method get. input url in field and chose te method ‘GET’ the url: https://api.restful-api.dev/objects then click run button. it should preview just like at the picture below:
Lets create our testcase then, create ‘test case’
3. Test Cases -> New -> Test Case -> input name -> ok
4. Add web service keyword -> send request -> click object -> chose test object on repository -> click ok -> type output ‘request’
To verify our response code ‘200’ as request we should add more step. in here, i chose “verify response code” keyword
5. Add web service keyword -> verify response code -> input response object ‘request’ -> type value status code ‘200’ -> ok
6. Run the testcase
After you finally understand to test api by run testcase, now i will show you how to run test suite and generate the report.
Now, second step, to create and run test suite. here’s the tutorial:
- Test suite -> new -> test suite
2. Add -> testcase browser -> chose testcases
3. Ok -> run test suite
Last step, reporting. To open report you should get through run test suite first. after successfull running test suite, now you can open the report. here’s the step you shoud follow:
Local document that you saved katalon project-> Reports -> file Test suites → chose HTML report
If you are reading in this paragraph, now you are succesfull finished reading and try this turorial for API Test.
Congratulation! try to explore more insights and techniques to effectively validate APIs accross various use case. If you have any more questions or need further clarification on any specific aspect of API testing, feel free to ask and happy testing!