簡體   English   中英

在空手道中 - 從另一個特征文件調用的特征文件以及變量值

[英]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 }
   

問題是,

  1. 在執行它時, runnerTest 將 tag1 配置為執行。 目前,它忽略了整個 ABC.feature 來執行,也沒有生成 cucumber 報告。

  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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM