问题
I am working on a Restful API that creates a new token after each request. So, in Postman I am refreshing my token environment variable after each request in Tests like following:
pm.test("Successfull Login Test", function () {
pm.expect(pm.response.text()).to.include('"result":"success"');
var res = pm.response.json();
pm.environment.set("token", res.token);
});
I wonder if it is possible to do this operation for all collection items? I mean I want to say to Postman, run this script after every request.
Thank you.
回答1:
How about using a collection, and the collection (or folder) can also have tests that are run after every request. Postman Collections/Folder Testing.
来源:https://stackoverflow.com/questions/62758297/is-there-any-way-to-run-a-test-script-after-each-request-in-postman-collection