I have a variable in one of the scenario of a feature file which I need to use in the request body of second feature file.
For Example:
A.feature
Scenario: Test
Given url 'abc'
* def number = 12345
And request {tyu:'#(number)',dhd:'lkj'}
When method put
Then status 200
B.feature
Scenario: Test2
Given url 'pqr'
And request {tyu:'#(number)'}
When method put
Then status 200
Note: Number variable in A.feature is a 6 digit number which is randomly generated everytime and the same should be passed in B.feature file.
Normally if you have two
Scenario
-s that depend on one another you have to combine them into one. Refer the docs here: https://github.com/intuit/karate#script-structureBut if you are really looking for how to initialize something and re-use it across all feature files, maybe you are looking for
karate.callSingle()
: https://github.com/intuit/karate#hooks