问题
I downloaded the karate-demo project and made this small changes:
in karate-config.js the first line of the function:
karate.log("Environment from command line: ",karate.env);
then I execute from terminal
mvn test -Dtest=InfoRunner -DargLine="-Dkarate.env=web"
in the output I should get:
Environment from command line: web
but it shown :
Environment from command line: null
for some reason is not passing the karate.env variable
回答1:
Thanks for mentioning this:
i found out that work if execute the following command mvn test -Dtest=InfoRunner -Dkarate.env=web
This is actually news to me. Can you provide your maven / java version ? Also maybe your local maven installation has been modified ?
For example:
$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T13:28:13+05:30)
Maven home: /Users/<>/dev/apache-maven-3.0.5
Java version: 1.8.0_112, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"
回答2:
When you remove -dargline
then it works.
来源:https://stackoverflow.com/questions/52191818/passing-karate-env-by-command-line-doesnt-work-as-expected