简体   繁体   English

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

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

My apologies it seems repetitive question but it is really troubling me.我很抱歉,这似乎是重复的问题,但它真的让我很困扰。

I am trying to call one feature file from another feature file along with variable values.我正在尝试从另一个功能文件中调用一个功能文件以及变量值。 and it is not working at all.它根本不起作用。

Below is the structure I am using.下面是我正在使用的结构。

my request json having variable name .我的请求 json 具有变量名称 Filename:InputRequest.json文件名:InputRequest.json

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

my featurefile1: ABC.Feature我的特征文件 1:ABC.Feature

Background : 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);   

Scenario: ABC call场景:ABC 调用

* configure cookies = null
Given url endpoint

And request request1
When method Post
Then status 200

Feature file from which I am calling ABC.Feature我从中调用 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. While executing it, runnerTest has tag1 configured to execute.在执行它时, runnerTest 将 tag1 配置为执行。 Currently, it is ignoring entire ABC.feature to execute and also not generating cucumber report.目前,它忽略了整个 ABC.feature 来执行,也没有生成 cucumber 报告。

  2. If I mention the same tag for ABC.feature (Which is not expected for me as this is just reusable component for me ) then it is being executed but sTransDateTime value is not being passed from XYZ.feature to ABC.feature.如果我提到 ABC.feature 的相同标签(这对我来说不是预期的,因为这对我来说只是可重用的组件)然后它正在执行但sTransDateTime值没有从 XYZ.feature 传递到 ABC.feature。 Eventually, InputRequest.json should have that value while communicating with the server as a part of the request.最终, InputRequest.json 在作为请求的一部分与服务器通信时应该具有该值。

I am using 0.9.4 Karate version.我正在使用 0.9.4 空手道版本。 Any help please.请提供任何帮助。

Change to this:改成这样:

{ sTransDateTime: '#(sTransDateTime)' }

And read this explanation: https://github.com/intuit/karate#call-vs-read并阅读此说明: https://github.com/intuit/karate#call-vs-read

I'm sorry the other part doesn't make sense and shouldn't happen, please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue很抱歉,其他部分没有意义,不应该发生,请按照以下流程操作: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 空手道:将变量从一个特征文件传递到另一个作为查询参数 - Karate : Passing variable from one feature file to another as a query parameter 空手道 API 测试 - 将变量从一个特征文件传递到另一个 - Karate API Testing - Passing variable from one feature file to another 从另一个功能文件(空手道框架)调用功能文件时出现“未定义”错误 - Getting "not defined" error while calling a feature file from another feature file (Karate framework) 空手道-从另一个特征文件中的响应中获取字段的值 - Karate- get value of a field from response in another feature file 如何使用空手道 API 测试将变量从一个特征文件调用到另一个特征文件 - How can I call a variable from one feature file to another feature file using Karate API Testing 如何将变量发送到调用空手道功能文件的文本文件...? - How to send a variable to a text file that calling to karate feature file...? 用变量调用空手道功能 - Calling karate feature with variable 空手道 API 框架 - 在另一个功能文件中调用 function - Karate API Framework - Calling function in another feature file 使用另一个变量从不同的特征文件调用场景 - Calling scenario from different feature file using another variable 从具有多个场景的特征文件中返回变量 - 空手道 - Returning Variable from Feature File With Multiple Scenarios - Karate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM