我刚开始使用空手道,并且想使用karate-config.js对其进行配置。 在Maven中,我有
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-core</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.6.0</version>
</dependency>
然后我将karate-config.js放在资源文件夹下:
function() {
var env = karate.env; // get java system property 'karate.env'
karate.log('karate.env selected environment was:', env);
karate.configure("ssl", true)
if (!env) {
env = 'dev'; //env can be anything: dev, qa, staging, etc.
}
var config = {
env: env,
AM_USERNAME: 'devuser',
AM_PASSWORD: 'devpass',
AM_HOST: 'https://am.'+env+'.example.net',
AM_AUTHENTICATE_PATH: '/am/json/realms/root/authenticate',
...
starter.java
@RunWith(Karate.class)
@CucumberOptions(features = "classpath:karate")
public class StartCucumberApiTest {
}
但是当我尝试跑步时,我得到了:
java.lang.RuntimeException:引导程序配置错误,对karate-config.js的评估失败: 引起原因:java.lang.RuntimeException:JavaScript评估失败:function(){ var env = karate.env; //获取Java系统属性'karate.env'
似乎Java无法评估karate-config.js
谢谢