I'm running tests using the Karate framework.
As a setup step, I need to create some entities using a REST API. I create them using callSIngle
in karate-config.js:
const result = karate.callSingle('classpath:path/to/createEntities.feature', config)
The feature has a Scenario Outline
, defining various entities that need to be created. The REST API returns an ID for each entity that is created.
How can I save these IDs? I tried several solutions, for example define a variable in the Background
section of the Scenario Outline
- doesn't work as it's overwritten by each test and only its last value is returned.
Background
* def ids = {}
.....
Scenario Outline:
....
* set ids.<index> = response.id
In this example, the result
will only have one value inside the ids
map, for the last scenario.