【发布时间】:2022-03-08 16:29:41
【问题描述】:
我的测试网址如下所示:
{{baseURL}}/api/v1/{{testName}}
当我在运行器中运行此测试时,它不会拉入 testName 变量。
我的 json 数据文件如下所示:
[
{
"testName": "12345"
{
"test1": "1234",
"test2": "2468"
},
{
"test1": "1357",
"test2": "9876"
},
"testName": "2468"
{
"test1": "1234",
"test2": "2468"
},
{
"test1": "1357",
"test2": "9876"
}
}
]
但这不起作用。
所以我试图从运行器中的.json 文件中调用变量,然后继续根据请求中的实际数据检查预期数据。然后当完成一个测试后,将继续进行下一个测试。
【问题讨论】:
-
这类似于这个问题:stackoverflow.com/questions/64260593/…;但是,我的问题与使用 JSON 文件有关。
-
pm.iterationData.get("myVariable");将帮助您从 csv/json 文件中获取价值。然后将其设置为全局/环境变量。 -
谢谢@lucas-nguyen-17,但我如何将它写在我的
.json文件中?这就是我感到困惑的地方。 -
您可以在收藏/文件夹的预请求中写入。还没有测试。更多信息在这里learning.postman.com/docs/running-collections/…
标签: json get postman postman-collection-runner