如何将要素文件本身作为变量传递?

时间:2018-05-09 06:21:28

标签: karate

我正在尝试这样做: sample_generic.feature

Scenario:
    * def result = call read('#(feature)') headers

我有另一个这样的功能文件: sample_caller.feature

Scenario:
   * def result = call read('sample_generic.feature') {feature: 'classpath:common/example.feature'}

当我尝试这样做时,我收到错误:

com.intuit.karate.exception.KarateException:
/****/test-suite/src/test/java/example/common/#(feature) (No such file or directory)
  at com.intuit.karate.Script.evalFeatureCall(Script.java:1647)
  at com.intuit.karate.Script.call(Script.java:1579)
  at com.intuit.karate.Script.evalKarateExpression(Script.java:228)
  at com.intuit.karate.Script.evalKarateExpression(Script.java:170)
  at com.intuit.karate.Script.assign(Script.java:598)
  at com.intuit.karate.Script.assign(Script.java:524)
  at com.intuit.karate.StepDefs.def(StepDefs.java:305)
  at ✽.* def result = call read('classpath:common/sample_generic.feature') {feature: 'example.feature'}(/*****/test-suite/src/test/java/example/common/example.feature:12)

是否有空手道支持动态调用功能文件本身的方法? 感谢

1 个答案:

答案 0 :(得分:1)

没关系。 我搞定了。 而不是'#(feature)',如果我们只通过功能,它就会很好。

Scenario:
    * def result = call read(feature) headers

这很有用!