在条件逻辑中驱动的数据无法按预期工作

时间:2019-06-28 05:52:12

标签: karate

我想用数据驱动测试条件逻辑中的另一个功能文件(正常的编程语言中有if-else if-else if-else,但可能不支持空手道超过两个条件)。

这是我的演示功能文件:

Feature: conditional logic call demo

  Scenario:

    * def switchVar1 = 1
    * def switchVar2 = 2

    * table testVars
    |switchVar1|switchVar2|
    |'theOne1'  | 'theTwo1' |
    |'theOne2'  | 'theTwo2' |


# here I can not do data-driven test the feature file: 'callUsage/module1/demo_module1.feature' 
 * eval if(switchVar1 == 1) 
     karate.call('classpath:callUsage/module1/demo_module1.feature') testVars

错误日志

flow.feature:30 - javascript evaluation failed: if(switchVar1 == 1) karate.call('classpath:callUsage/module1/demo_module1.feature') testVars, <eval>:1:84 Expected ; but found testVars
if(switchVar1 == 1) karate.call('classpath:callUsage/module1/demo_module1.feature') testVars
                                                                                    ^ in <eval> at line number 1 at column number 84

1 个答案:

答案 0 :(得分:1)

karate.call传递值不同于call,因为karate.call应该像函数一样被调用

尝试,

* eval if(switchVar1 == 1) karate.call('<FILE_PATH>', testVars) 

https://github.com/intuit/karate#karate-call