Data Driven Testing in Postman using CSV (2024) | TechGeekNext

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.

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:

  1. To use data from a file in Postman.
  2. To use data from a different request-response in Postman.

Take a look at our suggested post :

  1. 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.
  2. 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.

Let see the body of API be: POSTMAN DataDriven

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:
  1. Create a CSV file.
  2. Add email, password in columns of CSV file.
  3. Add possible test cases of email and password.
  4. POSTMAN DataDriven CSV
  5. Create a collection named Data-driven test.
  6. To get the variable from the CSV file, run this collection on Runner, click the Run button.
  7. POSTMAN DataDriven
  8. Collection Runner window will appear. POSTMAN DataDriven
  9. Iterations are the no. of data rows in the CSV file.
  10. Add CSV file in the Data option. The preview of the CSV file is displayed by the Preview button.
  11. Click on the Run button.
  12. The Result window will be displayed. POSTMAN DataDriven

Recommendation for Top Popular Post :