Pass additional parameters to karate-config.js via command line via Maven

蓝咒 提交于 2020-02-20 09:41:05

问题


I have additional settings that I need to pass to Karate when running via Maven that will be available in karate-config.js. Currently I can pass in a string using the karate.env property - is it necessary to encode my parameters as a JSON object and pass them in via this one property or can I do something like:

mvn test -DargLine="-Dkarate.env='production' -Dkarate.clientid='1234567890' ...

Such that I can then reference karate.clientid in karate-config.js where I can save it into the returned config object.

I'm sure I'm missing something obvious here...


回答1:


Yes ! Refer to the documentation for karate.properties['karate.clientid'].

Here is an example karate-config.js




回答2:


I've found but I didn't used examples. What I've done:

  • in gradle:

    task api(type:Test) { systemProperty "karate.clientId", System.properties.getProperty("karate.clientId")... }

  • in karate-config.js (in var config):

clientId: karate.properties['karate.clientId'] || 'xyz'

  • in command line:

'-Dkarate.clientId=abc' If I don't set clientId in my command line, the clientId will be 'xyz'



来源:https://stackoverflow.com/questions/46671916/pass-additional-parameters-to-karate-config-js-via-command-line-via-maven

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