Execution order of scripts in Postman collections/folders/requests

Postman's Collection (collection)/Folder (subfolder of the collection)/Request (request) has Pre-request Script (pre-request script) and Tests (post-request script). This function is similar to the Test Fixture function of different scopes
. Let's explore 3 questions:

  1. The order in which scripts are executed?
  2. Will the scripts set in the collection and subfolders be executed when the request saved in the collection/subfolder is sent separately?
  3. When using the Runner to run a collection, is the script in the collection/subfolder only executed once or every script executed once?

Preparation step
1. Create a new Collection, enter console.log("From: 集合-请求前脚本")and console.log("From: 集合-请求后脚本")save in Pre-request Script and Tests respectively

2 Create a new Folder under the Collection, enter console.log("From: 子文件夹-请求前脚本")and console.log("From: 集合-请求后脚本")save in Pre-request Script and Tests respectively

3. Create two new requests and save them under the 'subfolder'

 Start the test
1. Open the Postman console (menu bar->view->Show Postman Console)
2. Send request 1, view the console

It can be seen that: 1. The order of execution is from large to small. 2. Executing the script alone will also trigger the script set in Collection/Folder.
3. Open the Collection Runner and run the entire collection

It can be seen that the scripts in Collection/Folder will be executed once per request

Practical case

Optical theory is useless, you have to learn to follow along, and you have to do it yourself, so that you can apply what you have learned to practice. At this time, you can learn from some actual combat cases.

If it is helpful to you, please like and collect it to give the author an encouragement. It is also convenient for you to quickly find it next time.

If you don’t understand, please consult the small card below. The blogger also hopes to learn and progress with like-minded testers

At the right age, choose the right position, and try to give full play to your own advantages.

My road of automated test development is inseparable from the plan of each stage along the way, because I like planning and summarizing,

Test and develop video tutorials, study notes and receive portals! ! !

Guess you like

Origin blog.csdn.net/m0_59868866/article/details/130773913