I have two feature: first where I have arguments and second where I want to send argumnets from first feature.
First feature:
Feature: test
@dev
Scenario: test
* def arguments = { value: '123.00', jspath: '..transferData.amount',consent_body: 'classpath:consent_domestic.json' }
* def createConsentResult = call read('classpath:reuseable/features/changeConsentBody.feature') arguments
Second feature:
@ignore
Feature: Change consent body - 1 parameter
Background:
* url ''
* call read('classpath:reuseable/features/commonFunction.feature')
@act
Scenario : Change consent body - 1 parameter
* path 'consents'
* def consentBody = read(consent_body)
* print "jsonPath: "+jspath
* set consentBody jspath= value
When request consentBody
And method post
Then status 201
Here * def consentBody = read(consent_body)
karate sees 'consent_body' as a variable and uses value of this variable.
Here * print "jsonPath: "+jspath
karate sees 'jspath' as a variable and uses value of this variable and print: [print] jsonPath: ..transferData.amount
.
BUT here * set consentBody jspath = value
karate doesn't see 'jspath' as a variable and doesn't use the value of this variable. Instead , karate shows error:
changeConsentBody.feature:17 - unexpected path: jspath
In this case karate need to see 'jspath' as a variable and use the value of this variable.