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