问题
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 thankarate.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