将配置作为karate.callSingle()的一部分传递的问题

时间:2019-06-19 16:03:12

标签: karate

正如标题所述,尝试将配置项传递给我从karate-config.js中的callSingle()调用的功能文件时遇到问题。如果我仅传递1个参数(即功能文件的路径),那么一切都会按预期进行。我尝试从示例karate-config.js复制整个配置,但仍然遇到相同的错误。不胜感激。

karate-config.js:

function fn() {
  var env = karate.env; // get system property 'karate.env'
  karate.log('karate.env system property was:', env);
  if (!env) {
    env = 'kermit';
  }
    karate.log('karate.env system property was:', env);
  var config = {
    env: env,
    base_url: 'https://api.'+env+'.chdev.org',
    account_url: 'https://account.'+env+'.chdev.org'
  }

  var result = karate.callSingle('classpath:authorization/authorization.feature', config);
  karate.log(result);

  return config;
}

我遇到的错误:

16:48:10.548 [main] ERROR com.intuit.karate - evaluation of 'karate-config.js' failed: javascript function call failed: unexpected feature call arg type: class jdk.nashorn.internal.scripts.JO4
Exception in thread "main" java.lang.NullPointerException
    at com.intuit.karate.core.ScenarioExecutionUnit.init(ScenarioExecutionUnit.java:147)
    at com.intuit.karate.core.ScenarioExecutionUnit.run(ScenarioExecutionUnit.java:236)
    at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:164)
    at com.intuit.karate.core.FeatureExecutionUnit.run(FeatureExecutionUnit.java:73)
    at com.intuit.karate.core.Engine.executeFeatureSync(Engine.java:109)
    at com.intuit.karate.IdeUtils.exec(IdeUtils.java:64)
    at cucumber.api.cli.Main.main(Main.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

实际上,无论我作为第二个arg通过什么,我总是会得到jdk.nashorn类错误的变体。

2 个答案:

答案 0 :(得分:0)

<?php class User{ private $name; private $age; public $site; function __construct($q,$w,$e){ echo "User was successfully created!"; $this->name=$q; $this->site=$e; if($w>130 || $w<0){ unset($w); }; $this->age=$w; } public function getFullInfo(){ return "$this->name at the age of $this->age is a user of $this->site"; } } ?> 在我看来绝对是错字。

对不起,但是我认为对您来说最好的选择是执行以下过程:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

答案 1 :(得分:0)

彼得·托马斯先生已确认我作为github问题发送给他的项目按预期工作,证明了这是环境问题。 已通过将Maven和jdk8更新到最新版本来解决。