如何在空手道中参数化特征文件

时间:2019-10-26 12:21:18

标签: karate

我正尝试在如下所示的javascript函数中调用功能文件

sample.js:

  var authToken= function(urlparam1){
    var config = {urlparam: urlparam1}
    var result = karate.callSingle('classpath:test1.feature',config);
      karate.log('accesstoken in js file:', result.accessToken);
      return result.accessToken
    }

功能文件定义如下: test1.feature:

Feature: sample karate test script

  Background:
    * def url1 = '#(urlparam)'
    * url url1
    * def path1 = '/v1/customers/endpoint1'
  @tag1
  Scenario: sample scenario
    Given path path1
    When method get
    Then status 200
    * def accessToken = response

功能文件2: 在功能文件2中调用javascript函数

Feature: sample karate test script

  Background:

  Scenario: authenticate
   * def token1 =  authToken("http://127.0.0.1:9090")

值未替换为参数。

请让我知道如何将参数传递到特征文件以及如何访问特征文件中传递的参数

也让我知道功能文件到功能文件的组合。

我已经阅读了文档,但是无法正确理解示例

0 个答案:

没有答案
相关问题