I have a main feature file which brings up the mock and call an API. This main API will call other API in the background which goes to my karate mock server. I am able to validate incoming request and send out a response as well. In this incoming request on mock, I receive a transactionRef, which then appears in the response of my main API.
The flow is something like this
API1 Request
API2 Request (transactionRef) -> API2 Response
API1 Response (transactionRef)
What I want to check is these both are same. Is that possible? I tried setting a variable in mock feature but not able to access it in main feature.
Feature: stateful mock server
Background: Mock
Scenario: pathMatches('/abcd') && bodyPath('/Envelope/Body/infoRequest')!= null
* match karate.typeOf(request) == 'xml'
* xml respInfo = read('classpath:org/xbspro/hos/payloads/infoResponse.xml')
* def tranRef = $request/Envelope/Body/infoRequest/transactionId
* set respInfo/Envelope/Body/infoResponse/transactionId= tranRef
* def response = respInfo
Above is my mock feature. Below is my main feature
* call read('classpath:Abstract.feature')
* xml remResp = response
* match remResponse //transactionId == tranRef