Reputation: 43
Feature: Add data
Scenario: Add unique data
Given url
And request {name: '#(name)', lastName: '#(lastName)'}
And method POST
Then status 200
And def res = response
And def newId = res.data.id
One id will be generated as soon as above api is called. I want to use the id generated in another file to update the data. I have stored the id in 'newId' variable. How can I use this variable and its value in another feature file?
Upvotes: 2
Views: 4518
Reputation: 58058
This is explained in detail in the documentation - you should actually read it :)
So if you have a feature called.feature
as follows:
Feature:
Scenario:
* print newId
You can add this as the last line of the code you posted:
* call read('called.feature') { newId: '#(newId)' }
Upvotes: 1