Skip to content

Commit d2ddd8c

Browse files
authored
Update README.md
1 parent 15d38be commit d2ddd8c

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,45 @@ The `utils` functions are logically grouped in nested classes (namespaces) and i
2929
* [**Trace functions**](#trace-functions) for trace logging
3030
* [**General purpose functions**](#general-purpose-functions) for miscellaneous operations
3131

32-
## Folder level functions
33-
Before we get to the overview of the folder level functions, let's summarize how folder scripts work. Folder scripts can be defined for pre-requests and post-requests. For each request in the test collection being executed, Postman first runs pre-request scripts defined in all request parent folders starting from the top level folder. Then Postman runs request's pre-request script, executes the request, and runs all post-request scripts defined in the parent folder just as it did with folder pre-requests. Finally, it runs request tests. And it is worth repeating: this logic gets executed for every request in the test collection. You may not need to run any scripts for any or all folders, which is fine: you simple do not add any code to them; but when you do, you may need to run the code once per test collection execution or for every request in the collection.
32+
# Request workflow
33+
Before we get to the function definitions, let's summarize how requests work, so we know what gets executed when.
34+
35+
For each request in the test collection being executed, Postman first runs pre-request scripts defined in all request parent folders starting from the top level folder. Then Postman runs request's pre-request script, executes the request, and runs all post-request scripts defined in the parent folder just as it did with folder pre-requests. Finally, it runs request tests. And it is worth repeating: this logic gets executed for every request in the test collection. You may not need to run any scripts for any or all folders, which is fine: you simple do not add any code to them; but when you do, you may need to run the code once per test collection execution or for every request in the collection.
36+
37+
Let's use the following example:
38+
```
39+
- Collection
40+
|
41+
- Folder A
42+
|
43+
- Folder B
44+
|
45+
- REQUEST X
46+
- REQUEST Y
47+
```
48+
49+
Assuming that all folders and requests have pre-request and test scripts, the execution will go like this:
50+
51+
1. Collection pre-request script.
52+
2. Folder A pre-request script.
53+
3. Folder B pre-request script.
54+
4. REQUEST X pre-request script.
55+
5. REQUEST X
56+
6. Collection test script.
57+
7. Folder A test script.
58+
8. Folder B test script.
59+
9. REQUEST X test script.
60+
10. Collection pre-request script.
61+
12. Folder A pre-request script.
62+
13. Folder B pre-request script.
63+
14. REQUEST Y pre-request script.
64+
15. REQUEST Y
65+
16. Collection test script.
66+
17. Folder A test script.
67+
18. Folder B test script.
68+
19. REQUEST Y test script.
3469

70+
## Folder level functions
3571
Use folder level functions to run test or pre-request code attached to test collection folders (but not request scripts).
3672

3773
Folder level functions are grouped under the `utils.run` namespace and include:

0 commit comments

Comments
 (0)