-1

I'm using Postman to push data from a CSV in my Google cloud bucket to an app. I need to write a test to verify that one of the values in the CSV is all in uppercase.

4
  • 1
    Does this answer your question? Data Driven testing in Postman Tool – kaweesha Jun 23 '20 at 7:01
  • What is your goal? Are you going to verify your test data with postman? What should be the test case step by step? – Alexey R. Jun 23 '20 at 9:23
  • Could you add details like how are you pushing the csv from google cloud to app , i have added answer for a local csv – PDHide Jun 23 '20 at 10:33
  • please add comments to reopen the question if you are looking for data driven approach – PDHide Jun 24 '20 at 8:43
1

you cannot read files from local system in postman other than for iteration or sending it as request.

The two options you have is :

  1. Copy paste all the csv content and paste it in an environment variable , then:

In your pre-requiste or test script:

console.log(pm.environment.get("data"))
const parse = require('csv-parse/lib/sync')

//Environmental variable where we copy-pasted the csv content
const input =pm.environment.get("data");

const records = parse(input, {

 columns: true,

 skip_empty_lines: true

})


console.log(records)
  1. Pass environment variable through command line using powershell :

     $a= Get-Content -raw .\1.csv
    
     newman run .\test.postman_collection.json -e .\test.postman_environment.json -k -r "cli,htmlextra" --env-var data=$a
    

Now use the same above pre-requisite script.

0

The variable pm.request.body contains all info about your request body.

On the Pre-Request Scripts tab you can set up checks as you do on the Tests tab:

pm.test("All data is uppercase", function () {
    // You can use pm.expect() pm.request.body to validate things about your request body.
});

Not the answer you're looking for? Browse other questions tagged or ask your own question.