I have set two variables, let's say cityA = 'New York' and cityB = 'Las Vegas' in one feature and "exported" them with * def
expression. Now I want to use those variables in another feature
Scenario Outline: Successful transfer from <fromLocation> to <toLocation>
* call read('re-usable.feature')
Given request read('request.json')
When method post
Then status 200
Examples:
| fromLocation | toLocation |
| cityA | cityB |
| cityB | cityA |
with request:
{
source: "#(fromLocation)"
destination: "#(toLocation)"
}
My scenarios are failing because in request there is set cityA/cityB, not values stored under these names, I tried to use variables from karate-config file and even
Scenario Outline: Successful transfer from <fromLocation> to <toLocation>
* def res = call read('re-usable.feature')
Given request read('request.json')
When method post
Then status 200
Examples:
| fromLocation | toLocation |
| res.cityA | res.cityB |
| res.cityB | res.cityA |
and that is passing 'res.cityA', 'res.cityB' instead of New York/Las Vegas Moreover, I tried also following ways
Background:
* call read('re-usable.feature')
Scenario Outline: Successful transfer from <fromLocation> to <toLocation>
Given request read('request.json')
When method post
Then status 200
Examples:
| fromLocation | toLocation |
| cityA | cityB |
| cityB | cityA |
and
Background:
* def res = call read('re-usable.feature')
Scenario Outline: Successful transfer from <fromLocation> to <toLocation>
Given request read('request.json')
When method post
Then status 200
Examples:
| fromLocation | toLocation |
| res.cityA | res.cityB |
| res.cityB | res.cityA |
All presented cases return the same - varaible names not values. If in the request I set e.g. #(cityA)
instead of #(toLocation)
then everything is as expected but I cannot test other scenarios in this case
@PeterThomas you marked my last question as duplicate but link you have provided is not about my issue ;)