Organizing Tests, Functions, and Function Calls in Postman

In my API testing workflow in Postman, I often find myself repeating the same tests, functions, and function calls across multiple requests and collections. This can lead to redundancy and decreased efficiency in my testing process. Iโ€™m looking for tips and best practices on how to effectively organize tests, functions, and function calls in Postman to streamline my workflow and make it more manageable.
I have a variety of requests with similar test scenarios, and I want to avoid duplicating test scripts and functions.

(Video)

Images:



Postman runs on the principal of collections, folders and requests.

With a tests tab at each of those levels.

If you want to run the same test for every request in a collection or folder, you would put it in the appropriate test tab, but it does mean it will run for every request at that level. (which ultimately means I hardly ever use this feature).

It doesnโ€™t have the concept of shared test cases in the traditional sense (which would probably be a feature request).

There are various topics on the forum about using functions, so I would recommend a quick search in the first instance. You can store functions as global variables and use the JavaScript eval function, or put the functions in pre-request scripts at the collection or folder level. Both options appear to work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.