我想通过mvn命令在karate-config.js中传递多个参数

我想通过mvn命令在karate-config.js中传递多个参数

问题描述:

我想在mvn命令中传递多个参数,并且应该在karate-config.js文件中读取.

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'"

我不想声明任何.prop文件,想要在运行时获取这些值. 在道具下方被定义为读取这些参数,但无法从中实现:

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

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

而不是使用argLine尝试直接传递它,

Instead of using argLine try passing it directly,

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

我建议不要将karate.用作其他参数的前缀 而不是karate.env,而是尝试使用您的应用程序名称. 例如,

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

来到karate-config.js

coming to the karate-config.js

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

这应该有效.