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
解决方案
将值传递给karate.call
不同于call
askarate.call
应该像函数一样调用
尝试,
* eval if(switchVar1 == 1) karate.call('<FILE_PATH>', testVars)
推荐阅读
- javascript - 每次迭代使用不同参数的 DOM 操作 onclick 函数
- python-3.x - Airflow 实例不通过 SFTPsensor 连接到边缘节点服务器(SSH 连接类型)
- c++ - 提升:多精度
- windows - Neo4j 桌面中的应用程序初始化错误
- android - 在firebase身份验证android中显示加载(进度)栏
- 6502 - 为什么 X 和 Y 索引寄存器是 8 位的?
- azure - 如何在 Azure 中创建具有委派子网的专用终结点?
- python - 我想从 KML 文件中提取坐标
- css - VueJS中传递的文本太长时,如何有条件地缩放组件标题元素大小?(使用 Sass 和 Flexbox)
- docker - django 和 mysql 在 docker 中没有连接在一起