【问题标题】:How to add profile variable in Karate如何在空手道中添加配置文件变量
【发布时间】:2018-08-29 09:57:12
【问题描述】:

目前我正在使用以下命令来运行我的功能文件:

mvn test -Dcucumber.options="--plugin html:target/cucumber-html --tags @dogs" -Dtest=TestParallel.java  -Dkarate.env=Pets

但我希望在调用运行命令时添加另一个变量。像这样的:

mvn test -Dcucumber.options="--plugin html:target/cucumber-html --tags @dogs" -Dtest=TestParallel.java  -Dkarate.env=Pets -Dname=Charlie

我该怎么做?

【问题讨论】:

  • @PeterThomas 完成

标签: karate intuit


【解决方案1】:

您可以结合使用 Java 系统属性和读取 karate.properties 来传递额外的动态参数

mvn test -Dtest=TestParallel.java  -Dkarate.env=pets -Dmy.name=foo

然后在karate-config.js

var myName = karate.properties['my.name'];

甚至在任何功能文件中:

* def myName = karate.properties['my.name']

请注意-Dcucumber.options="--plugin html:target/cucumber-html" 对空手道和will be deprecated 未来没有任何影响。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    • 2019-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多