【发布时间】:2019-08-01 12:53:33
【问题描述】:
我有一个值列表,可用于我的 json 请求中的标题字段。我想在 common.feature 文件中存储一个函数,该函数在执行场景时随机化标题值。
我尝试使用自述文件中常用实用程序选项卡上提供的随机数功能。我已经成功生成了一个随机数,下一步将在 jsonpath 行中使用该随机生成的数字,以便从我的 json 数据列表中检索一个值。
* def myJson =
"""
{
"title" : {
"type" : "string",
"enum" : [
"MR",
"MRS",
"MS",
"MISS"
[...]
]
}
}
"""
* def randomNumber = random(3)
* def title = get[0] myJson.title.enum
* print title```
The code above works but I would like to randomize the number within the get[0]. How is this possible in Karate?
【问题讨论】: