Two types of scripts in postman:
- Pre-request script (It will run the script before execution)
- Test script (it will run the script after execution)
Order of execution:
Pre-request --> Request --> Response--> Test script
Execute the pre-request script and test script in 3 levels.
- Collection level
- Folder level
- Request level
- If we give scripts in pre-request and test scripts at all levels. The order will be executed in the following manner.
- Collection -> Folder-> Request (until this pre-request) -> Request -> Response -> Collection -> Folder -> Test script.
Variables:
- Variables are created to reduce the effort in updating data every time. In Postman, we are also creating variables to update data every time.
- For example, some parts of the URL are common across all the requests ("https://localhost3000"). This can be stored in one variable and can be used anytime whenever we want.
- If localhost number 3000 changes also, we can update the variable, it's a one-time update and can be updated everywhere.
Types of variables:
- Global - Accessible in Workspace
- Collection - Accessible within the collection.
- Environment - Accessible in all collections, but we need to switch to a particular environment.
- Local - Accessible only within the request (Specific to Request).
No comments:
Post a Comment