问题
I am using an authorization token in all my feature files . To generate the authorization token i need to call a particular feature file(token.feature) . Since I am using the token in all features I keep calling the same feature file again and again. The solution i found is the use of karate.callSingle() in karate-config.js but i dont know how to use karate.callSingle().
回答1:
In karate-config.js
you can do this:
var config = { myprop: 'myvalue', myurl: 'somevalue' };
var result = karate.callSingle('classpath:token.feature', config);
config.token = result.token; // assuming you did 'def token'
return config;
Now all your features can use the variable token
.
This is explained in the docs: https://github.com/intuit/karate#hooks
来源:https://stackoverflow.com/questions/51288342/how-to-use-karate-callsingle-in-karate-config-js