Hi,
I have a json body with multiple variables that I’d like to update dynamically and run each test on it. I want to avoid having to create multiple POSTs for each scenario.
Body:
“Category”: “{{Organization}}”,
“Matter”: {{Matter}},
“WorkOffice”: “{{WorkOffice}}”,
“BillOffice”:{{BillOffice}}
Test1:
pm.environment.set(“Organization”, “Organization1”);
pm.environment.set(“Matter”, 0001);
…
let responseData=pm.response.json();
pm.test(“NOTAXOUT”, function () {
pm.expect(responseData.GroupCode).to.equal(“NOTAXOUT”);
});
Test2:
pm.environment.set(“Organization”, “Organization2”);
pm.environment.set(“Matter”, 0002);
…
let responseData=pm.response.json();
pm.test(“5%”, function () {
pm.expect(responseData.GroupCode).to.equal(“5.00”);
});
Including the Postman Training links under “Other Resources”.
I would recommend the “Galaxy APIs 101” course first as it gets you used to the application features.
Then the “Galaxy Testing and Automation” course which teaches you how to assert the responses. It includes using variables and basic examples of the collection runner\data files.
Further information on using data files can be found here.
The data you want to set, and the tests are the the same for both requests with the only difference being the values, so using a data file should achieve your goal.