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

Viewed 528

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. Filename:InputRequest.json

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

my featurefile1 : 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);   

Scenario: ABC call

* configure cookies = null
Given url endpoint

And request request1
When method Post
Then status 200

Feature file from which I am calling 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. Currently, it is ignoring entire ABC.feature to execute and also not generating cucumber report.

  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. Eventually, InputRequest.json should have that value while communicating with the server as a part of the request.

I am using 0.9.4 Karate version. Any help please.

1 Answers
Related