Search code examples
testingsoapcucumberkarate

Karate - How to call multiple external features from a single main feature


Feature: Principal feature

Background:
    * url 'http://example.com'
   
    Scenario: Feature calling

       
    * def inputTable = call read('input_table.feature')  
    * call read('my_call.feature') inputTable.inputTestData

where the data table file is:

//input_table.feature
Feature:TABLE_TEST
Scenario:TABLE_TEST
    * table inputTestData
|inputName|outputName|
|requestA|responseA|

this throw me an error of:

ERROR com.intuit.karate - feature call failed: .../input_table.feature
arg: null
input_table.feature:3 - evaluation (js) failed: requestA, javax.script.ScriptException: ReferenceError: "requestA" is not defined in <eval> at line number 1
stack trace: jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:470)

but instead if i call the my_call feature with the data table defined inside in the Examples field it works correctly.

Any help?


Solution

  • There's a subtle difference between Examples and table. Maybe you meant to do this:

    * table inputTestData
    |inputName|outputName|
    |'requestA'|'responseA'|
    

    Read the docs: https://github.com/intuit/karate#table