Is there any way to run a test script after each request in Postman Collection?

余生长醉 提交于 2021-02-08 11:53:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!