Using environments and variables to dynamize requests
When we want to test an API, we need to test it on several environments for better results. For example, we will test it on our local machine and development environment, and then also on the QA environment. To optimize test implementation times and to avoid having a duplicate request in Postman, we will inject variables into this same request to make it testable in all environments.
So, in the following steps, we will improve our requests by creating an environment and two variables; then, we will modify our requests in order to use these variables:
- In Postman, we will start by creating an environment that we call
Local
, as shown in the following screenshot:
- Then, in this
Local
environment, we will insert a variable namedPostID
, which will contain the value to pass in the URL of the request. The following screenshot shows the...