Introduction to API Testing
API: API stands for an application programming interface. API is used to communicate and exchange data between two separate software on different platforms over the internet. It is of two types: SOAP(Simple object access protocols ) and REST(Representational state).
API testing is a process that is related to the business logic layer of the software. In this process, we are fully concentrated on the data, not on the look of the application. We use API testing software and get a response instead of the standard user inputs and outputs. A Tester performs API testing, and the application is required to interact with API.
Test cases for API testing:
- Verify the return response: This process is related to authenticate the return output according to the given input. Tester submits different types of input and checks the return output.
- Check response time: To check the response time of the submitted request for a return response. Response time for a request varies according to the given input.
- Verify empty response and improper messages: When there is not any return value according to the submitted request, then check the API behavior for a particular application. An empty response can be handled by giving an alert in the application at the user end.
- Unit testing: In the unit testing check the API response for a single operation.
- Integration testing: Functional testing check the API response for multiple operations.
- Load Testing: Load testing ensures the capability of the Server to handle the expected number of users simultaneously accessing the application.
- Security Testing: Security testing is performed to verify the API is secure from all external threats and attacks. We can achieve this process by doing penetration( to detect vulnerabilities of an application from an attacker’s perspective) and fuzz testing( to ensure the security loopholes) to Verify the API is secure.
- Invoking event or interrupt: If the response of the API call some event or interrupt the functionality of the application then it should be tracked.
Tools to perform API Testing:
There are various tools available in the market to use for API testing such as the list mentioned below:
- Soap UI
- Katalon studio
- Rest- assured
Here we will do API testing using Postman. A postman is an open-source testing tool used for API testing. It is easily available in the market and an individual can also install it as google chrome extension as well in a system according to the system configuration (https://www.getpostman.com/downloads/).
How to use Postman:
Below is a list of the features of Postman:
- New: It is used to create a new request, collection, and environment.
- HTTP Request: It is a drop-down field with different request options such as GET, POST, COPY, DELETE, HEAD, LINK, OPTIONS, etc. But the most commonly used request is GET and POST.
- Request URL: Here you will enter the URL to communicate with API.
- Send: After click on the send button request is submitted.
- Params: here you will enter the parameters required for the request such as key values.
- Authorization: Sometimes authorization is required to access the API such as Username and a password is required to access the API data.
- Headers: Here you can set the headers such as content type according to the requirement of the organization.
- Body: It is used to customize the details required in the request. It is commonly used in the POST request.
- Pre-request Script: It is used to set the environment for the request and to ensure that the request will be running in the correct environment.
- Tests: Test is used to create scripts and to validate the retrieved data from the request.
How to test API using Postman:
Here we will take an example of API with a single user record. To test this we need to follow the below-mentioned steps:
Steps to perform API testing:
- Set HTTP Request to GET.
- Enter the URL in the Request URL(https://reqres.in/api/users/2)
- Click on the send button.
- You will see the record of the user in the Body.
We get all data according to the sample request.
Screenshot: In the screenshot, we can see the status is 200 and the time taken to the response of the request is 614 ms.
Knowledge of .NET is quite rewarding in the IT industry. If you have got some skills in the .NET framework then a .NET certification from StudySection can prove to be a good attachment with your resume. You can go for a foundation level certificate as well as an advanced level certificate in the .NET framework.