I want to pass multiple arguments in karate-config.js through mvn command

时间秒杀一切 提交于 2019-12-21 21:06:10

问题


I want to want pass multiple arguments in mvn command and and that should be read in karate-config.js file.

e.g: mvn test -DargLine="-Dkarate.env='gdcStaging', -Dkarate.source='false', -Dkarate.natco='gdc'"

I didn't want to declare any .prop files, want to get these values at run time. Below prop. are defined to read these arguments but unable to achieve from this:

var environment = karate.env;
var natco = karate.properties['karate.natco'];
var isLocal = java.lang.System.getenv('karate.source');

I need help to achieve this

karate-version=0.9.0

I had also referred to this link :Pass additional parameters to karate-config.js via command line via Maven but not worked


回答1:


Instead of using argLine try passing it directly,

mvn test -Dkarate.env=gdcStaging -Dkarate.source=false -Dkarate.natco=gdc

I suggest not to use karate. as a prefix to your arguments other than karate.env, instead try using your application name. eg,

-Dmyapp.source=false

coming to the karate-config.js

var natco = karate.properties['myapp.source']

This should work.



来源:https://stackoverflow.com/questions/54229825/i-want-to-pass-multiple-arguments-in-karate-config-js-through-mvn-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!