Data Driven Testing in Postman using CSV (2024)
In this tutorial, we will understand the POSTMAN Parameterization DataDriven Testing and Reading CSV files. In this tutorial, we will first understand Parameters for DataDriven Testing and then create and Read CSV or Excel files.
Postman Tutorial :
- Download and Install Postman on Windows
- Write Postman Test case
- Share Collection in Postman
- Postman Assertions and validating the Response
- Data Driven Testing in Postman using CSV
- Postman Interview Questions and Answers
DataDriven Testing in Postman Parameterization
Ans:
In POSTMAN, DataDriven Testing means, there is one test that is run many times with different data variables. In simple words, Data-driven Testing is nothing but getting data tested from a different file. In Different Data storage applications, applications Data for Excel, Notepad, Wordpad, etc. can be stored.
Data are stored in different formats and not in a single format.
In two different ways, DataDriven testing can be done. The two ways to use the Data are:
- To use data from a file in Postman.
- To use data from a different request-response in Postman.
Take a look at our suggested post :
To use data from a file in Postman
The data stored in the file for different applications such as JSON, HTML, CSV, etc can be used. The commonly used formats are JSON and CSV.To use data from a different request-response in Postman
The first step is to create variables and then the data stored in the file can be used.
Now Let's go to the API and perform DataDriven Testing for using data from a file.
Now add test in the Test Tab
{
pm.test("Status code is 200" , function(){
pm.response.to.have.status(200);
});
var nm = pm.variables.get("name");
var rl = pm.variables.get("role");
pm.test("Check name " +nm, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.name).to.eql(nm);
});
pm.test("Check role " +rl, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.role).to.eql(rl);
});
}
Data-driven testing using CSV FILE - POSTMAN
-
For Reading CSV file following are the steps to be followed:
- Create a CSV file.
- Add email, password in columns of CSV file.
- Add possible test cases of email and password.
- Create a collection named Data-driven test.
- To get the variable from the CSV file, run this collection on Runner, click the Run button.
- Collection Runner window will appear.
- Iterations are the no. of data rows in the CSV file.
- Add CSV file in the Data option. The preview of the CSV file is displayed by the Preview button.
- Click on the Run button.
- The Result window will be displayed.