空手道-我可以在方案大纲中发送多个动态数据

时间:2019-02-05 07:13:09

标签: karate

下面是代码:

Feature:
Background:

    * def Json = Java.type('Json')
    * def dq = new Json()
    * def result = dq.makeJson()
    * def Sku = dq.makeSku()

    Scenario Outline: id : <id> 
    * print '<id>'  #From result
    * print '<abc>' #From Sku


Examples:
|result|Sku|

以下是我需要的输出。空手道有可能吗?

If i have id = {1,2} and abc = {3,4} i want output to be
        id = 1 and abc = 3
        id = 1 and abc = 4
        id = 2 and abc = 3
        id = 2 and abc = 4

也可以对两个以上的变量输入执行此操作吗?

1 个答案:

答案 0 :(得分:0)

自己编写置换逻辑,并用结果构建一个数组。 请注意,您可以使用karate.forEach()

遍历JSON的键值对。

然后使用(第二个功能文件的)数据驱动的循环调用:

# array can be [{ id: 1, abc: 3 }, {id: 1, abc: 4 }] etc
* def result = call read('second.feature') array

或动态方案概述:

Scenario Outline:
* print 'id = <id> and abc = <abc>'
Examples:
| array |

参考: https://github.com/intuit/karate#data-driven-features https://github.com/intuit/karate#dynamic-scenario-outline

相关问题