在空手道中 - 从另一个特征文件调用的特征文件以及变量值

In Karate - Feature file calling from another feature file along with variable value

抱歉,这个问题似乎是重复的问题,但确实让我很困扰。

我正在尝试从另一个特征文件中调用一个特征文件以及变量值。它根本不起作用。

下面是我正在使用的结构。

我的请求json有变量名.文件名:InputRequest.json

{
  "transaction" : "123",
  "transactionDateTime" : "#(sTransDateTime)"
}

我的特征文件 1 : ABC.Feature

Background:

  * def envValue = env
  * def config = { username: '#(dbUserName)', password: '#(dbPassword)', url: '#(dbJDBCUrl)', driverClassName: "oracle.jdbc.driver.OracleDriver"};
  * def dbUtils = Java.type('Common.DbUtils')            
* def request1= read(karate.properties['user.dir'] + 'InputRequest.json')
* def endpoint= '/v1/ABC'
* def appDb = new dbUtils(config);   

场景:ABC 电话

* configure cookies = null
Given url endpoint

And request request1
When method Post
Then status 200

我调用的功能文件ABC.Feature

@tag1
**my featurefile1: XYZ.Feature**

    `Background`: 
    
          * def envValue = env
    
    Scenario: XYZ call
       
    * def sTransDateTime = function() { var SimpleDateFormat = Java.type('java.text.SimpleDateFormat'); var sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'+00:00'"); return sdf.format(new java.util.Date()); }
    
    * def result = call read(karate.properties['user.dir'] + 'ABC.feature') { sTransDateTime: sTransDateTime }
   

Problem is,

  1. 在执行它时,runnerTest 将 tag1 配置为执行。 目前,它忽略整个 ABC.feature 执行,也不生成黄瓜报告。

  2. 如果我为 ABC.feature 提到相同的标签(这对我来说不是预期的,因为这对我来说只是可重用的组件)那么它正在执行但是 sTransDateTime 值未从 XYZ.feature 传递到 ABC.feature。最终,InputRequest.json 在作为请求的一部分与服务器通信时应该具有该值。

我正在使用 0.9.4 空手道版本。请帮忙。

改为:

{ sTransDateTime: '#(sTransDateTime)' }

并阅读此解释:https://github.com/intuit/karate#call-vs-read

很抱歉,其他部分没有意义,不应该发生,请按照以下流程进行:https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue