[英]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,问题是,
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 报告。
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.