Hi
I am using CSV data file in the Postman Collection Runner
{{username}}
{{password}}
{{message}}
My csv file looks like
|username|password|message|
|testone|test123||
|testtwo|test 456|Login Unsuccessful|
|testthree|test789|Registration not complete|
Now when I execute this test via runner how do I validate the message in response body against the message specified in my file
@postmnrequest You can access the data file variable value in the Test
script using the data[keyName]
format or pm.iterationData.get(keyName)
Then, you can further grab the field that you want to test from your response.
An example test would be like this:
pm.test('Message validation', function () {
let expectedMessage = data['message'],
message = _.get(pm.response.json(), 'message'); // you can modify this according to your response body
pm.expect(message).to.equal(expectedMessage);
});
2 Likes