If you need to use different Test Data for different Executions(for example, if you need to use different URLs for Staging, QA, or Production), we can make use of Global Parameter Test Data.
In this article, we will see how we can use a Global Parameter Test Data in REST API Steps.
We will be mentioning Global Parameter Test Data as Global Parameter going forward.
Using Global Parameter in REST Steps
Before we begin, let us clear it out that Global Parameter can be used only in the URL for a REST API Test Step as of now. More features will be added going forward.
And for this, we simply need to append the Global Parameter with the URL as it is used in normal Test Steps. The Test Data will be translated into its value when the REST Step is run.
Let us assume that we need to use two types of URL(testing and production) for the same Test Case. Following are the Global Parameter sets created.
Note: The Testing URLs base_url value 'https://qa.google.com' is just a sample URL and is non-existent. Therefore the Test will fail in this case.
Use the Global Parameter base_url in the URL for the REST API Test Step as shown below:
Here's the Step Result for the failed Run:
That's how we can use Global Parameters in REST API Test Steps.