Have a variable 'dummyVariable' in a function of MyService.java file. Now I am calling an endpoint 'dummyEndpoint' that sets the value of 'dummyVariable' to true or false.
I want to extract this value of 'dummyVariable' after I call 'dummyEndpoint' using Karate feature files by call() method.
Further I want to perform different actions in feature file depending on this value being true or false. Basically this can be treated as knowing whether an experiment is on or off in java service during an endpoint calling.
More crisp explanation-> dummyEndpoint called from Karate file-> sets a variable's value in java service -> want to extract that value after call completion.
//MyKarateFile .feature file
Scenario: Make a call to service
Given url baseUrl
And path ‘/some-path’
And header Authorization = api
And param environment = env
And request req
When method POST
Then status 200
//want to check dummyVariable 's value here
//MyService .java
private final DummyVariableSetter dummyVariableSetter;
public int myFunction() {
boolean dummyVariable = dummyVariableSetter.isDummyVaribaleOn();
if(!dummyVariable) return 0;
return 1;
}
//DummyVariableSetter .java
public boolean isDummyVaribaleOn() {
return getVersion(“some-property”) >= 0;
}
tried using exits() method of Karate but did not worked.