how to pass a global variable to the reusable feat

2019-07-10 03:11发布

问题:

I am starting to use Karate to test webservices and I want to pass a global variable to the classpath of a reusable feature file. Does anyone have an idea? Thanks in advance.

回答1:

This is what karate-config.js is for. Refer the documentation: https://github.com/intuit/karate#karate-configjs

for example if you have the following simple karate-config.js file:

function fn() {   
  return { foo: 'bar' }
}

You will be able to refer to the variable foo in any feature file:

* print 'the value of foo is:', foo


标签: karate