如何在每个空手道功能中获取值(例如:baseURL)? [英] How to get a value (ex: baseURL) in every Karate feature?

查看:72
本文介绍了如何在每个空手道功能中获取值(例如:baseURL)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为所有功能获取一个公共变量.例如:基本URL和路径(在某些功能中).我对空手道官方短裙不太了解该怎么做. 我输入了user.feature

I would like to get a common variable for all features. Ex: base URL and path (in some features). I don't understand well in Karate official tutos what to do exactly. I put in user.feature

`Background:
* url urlBase
* path users

在karate-config.js中

In karate-config.js

function() {
  var env = karate.env;
  karate.log('karate.env system property was:', env);
  if (!env) {
    env = 'dev';
  }
  var config = {
    env: env,
    appId: 'my.app.id',
    appSecret: 'my.secret',
    baseURL: 'https://someurl/',
    users: 'users'
  };
  karate.configure('connectTimeout', 5000);
  karate.configure('readTimeout', 5000);
  return config;
}

在我的跑步者班上:

@RunWith(Karate.class)
@CucumberOptions(features = "classpath:features/users/User.feature")
public class TestRunner{
    }
}

User.feature和karate-config.js位于同一文件夹中,Runner类位于另一个文件夹中. 这样对吗?还是我需要指定更多内容?

User.feature and karate-config.js are in the same folder and Runner class is in another. Is it right? or I need more things to specify?

推荐答案

不,这是不对的.我建议您参考Karate的快速入门文档,您可以在其中生成一个简单的项目.首先运行该文件,然后尝试从karate-config.js设置URL.一切顺利.

No this is not right. I suggest you refer to the quickstart documentation of Karate where you can generate a simple project. Get that running first, and then try to set the URL from the karate-config.js. All the best.

这篇关于如何在每个空手道功能中获取值(例如:baseURL)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆