Get karate parameter inside ExecutionHook Implementation class

97 Views Asked by At

I have the below karate-config.js file where I am reading the globalJson file.

function(){
  
    var globalJsonObj = '';
    var config = {
        globalJsonObj : '',
    };
    config.globalJsonObj = read('classpath:global-config.json');
    
    return config;
}

Now I have implemented ExecutionHook class. In the afterFeature method I want to access lobalJsonObj.

Is there a way in which I can access this?

1

There are 1 best solutions below

0
On BEST ANSWER

I don't recommend doing so much with the ExecutionHook - please find an alternative if possible, because the API may change in the future. This is why it is not in the official documentation and readme. If you are needing so much of control, contribute code to the main framework or suggest changes instead.

That said, you can try ScenarioContext.eval("globalJsonObj").getValue() - if you still have questions, please read the source code.