testaway
testaway

Reputation: 1

How to parameterize tests for each iteration in Postman collection?

My GET request goes like this:

<some ip>/search?IW_INDEX={IW_INDEX}&IW_FIELD_WEB_STYLE={IW_FIELD_TEXT}

The data file is as follows:

IW_INDEX,IW_FIELD_TEXT
index1,text1
index2,text2

My test for iteration 1 is as follows:

tests["parameter1"] = responseBody.has("value=\"19\"");

Now this value 19 will change depending upon the iteration and might be 20 in iteration 2.

Is there a way to provide expected test results iteration-wise in Postman?

Upvotes: 0

Views: 985

Answers (1)

Roni Yaniv
Roni Yaniv

Reputation: 59921

I think you could do it by adding a column to your CSV file with "expected_result" and in the test, call that value by {{data.expected_result}}, so your test should probably look like:

tests["parameter1"] = responseBody.has("value=\"{{data.expected_result}}\");

Upvotes: 2

Related Questions