I am using same set of data in most of my API requests, for ex. date ranges FromDate & ToDate. However, if i wish to change the date range then i will have to change it for all the Scenario Outlines. To avoid this, can i define the date ranges in the background section & use the variable name all over in Scenario Outline Examples tables? Can that be done in karate? Please help. Thanks.
Tried many ways but unable to pull if off somehow.
Feature: Verify that products are properly returned by the API Background: * configure ssl = true * url 'https://......' And def FromDate1 = '2019/06/27' And def ToDate1 = '2019/06/27'
Scenario Outline:
Given path 'GetContext'
And param FromDate = '<FromDate>'
And param ToDate = '<ToDate>'
And param CompAreaId = '<CompAreaId>'
And param RegId = '<RegId>'
When method get
Then status 200
* def res = response
* print 'response:', response
Examples:
| FromDate | ToDate | CompAreaId | RegId |
| FromDate1 | 2019/06/27 | 20 | 4 |
| 2019/06/28 | 2019/06/28 | 21 | 5 |
| 2019/06/29 | 2019/06/29 | 22 | 6 |
I should be able to use the variable names that contain the value to be used in the Examples table in Scenario Outline.