WE have heard about API testing a lot. What is this API testing and why this is so important. In this blog I am going to explain what is this API testing and How to use postman for API testing.
What’s an API
API is an acronym for Application Programming Interfaces. APIs are used to facilitate the integration between different systems. In simple terms, APIs act as a communication bridge that helps to interact with different software components and applications.
How does an API work
An API request is generated by the client application and an API call is sent to the destination application to process the API request. This call has a request type and it consists of an endpoint, a header, and sometimes a request body as well. Once the API Server receives the request, it will process the request and send a response to the client application as per the requested information.
APIs that follow the constraints from REST architecture falls under the REST protocol. REST standards consist of HTTP methods such as GET,POST,PUT and DELETE.
SOAP is a protocol used for exchanging structured information in the implementation of web services. It defines a set of rules for message formatting and communication.
What is Postman?
API functionalities can be tested using many tools. Postman is one such tool which is widely used among developers and testers in the industry.
This simple and user-friendly interface helps when it comes to documenting, designing, and testing APIs. You can create requests to API endpoints, send various types of data, and examine responses effortlessly with Postman. Its simple and informative graphical user interface makes it easy for even a less experienced beginner to interact with APIs without digging into complex code.
Let's Understand how postman tool works and different features of the Postman tool.
GET Requests
Get requests are used to retrieve information from the given URL.
In this Workspace
1. Set HTTP request to GET.
2. In the request URL field, put 'https://userapi-8877aadaae71.herokuapp.com/uap’ link.
3. Click send button
4. You can see Status:200 OK response code.
5. Your Test has run successfully . You can see the results in the response window
POST Requests
post requests are used to create a new data from the given URL.
In this Workspace
1. Set HTTP request to POST
2. In the request URL field, put 'https://userapi-8877aadaae71.herokuapp.com/uap/endpoint‘ link
3. Select raw and JSON
4. Add request body and Click send button
5. You can see Status : 201 Created message and also created response body.
PUT Requests
PUT requests are used to update the existing data.
1. Set HTTP request to PUT
2. In the request URL field, put 'https://userapi-8877aadaae71.herokuapp.com/uap/endpoint‘ link
3. Add request body and Click send button (request body should be updating information)
4. we can see the response code 200 OK populated in the Response body.
5. The Response body shows the updated data
DELETE Requests
DELETE request deletes a resource already present in the server
1. Set HTTP request to DELETE
2. In the request URL field, put 'https://userapi-8877aadaae71.herokuapp.com/uap/endpoint‘ link
3. Click send button.
4. Response code populated in the Response.
5. The Response shows the status as success. The record gets deleted from the server.
Data Driven Testing in Postman
Data-driven testing can be a very effective approach in testing an API against different data-sets. Postman supports CSV and JSON files to get data for the test scripts. The data-driven approach is useful when we need to execute a test with multiple sets of Data
Using CSV file:
Using JSON file:
Data-driven testing can be a very effective approach in testing an API against different data-sets. Postman supports CSV and JSON files to get data for the test scripts. The data-driven approach is useful when we need to execute a test with multiple sets of Data
Here I am going to explain how we can implement Data Driven Testing using CSV file.
1. First Create a CSV file.
2. Add batchDescription, batchName, batchNoOfClasses, batchStatus, programId in columns of CSV file
3. Add possible test cases for the above options.
4. Create a collection, for example name it as Data-driven test
5. To run this collection click on Run button.
6. As I showed here Run button will appear.
7. Iterations are the no. of data rows in CSV file
8. Click on Select File. Add your CSV file here. As soon as you add the file preview button appears here.
9. Click on Run button .
10. Result window will be displayed
This is the simple explanation of different request in Postman and Data Driven Testing in Postman using CSV file. Hope you Understand this……..
Happy Learning…………………..
Comentarios