使用不同的数据多次在Postman中运行请求仅运行一次 [英] Running a request in Postman multiple times with different data only runs once

查看:932
本文介绍了使用不同的数据多次在Postman中运行请求仅运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Postman的新手,遇到了一个反复出现的问题,无法解决。
我试图使用在预请求脚本上建立的数据数组多次运行相同的请求,但是,当我转到运行器时,请求仅运行一次,而不是3次。

I am new to Postman and running into a recurrent issue that I can’t figure out. I am trying to run the same request multiple times using an array of data established on the Pre-request script, however, when I go to the runner the request is only running once, rather than 3 times.

预请求脚本:

var uuids = pm.environment.get("uuids");

if(!uuids) {
uuids= ["1eb253c6-8784", "d3fb3ab3-4c57", "d3fb3ab3-4c78"];
}

var currentuuid = uuids.shift();
pm.environment.set("uuid", currentuuid);
pm.environment.set("uuids", uuids);

测试:

var uuids = pm.environment.get("uuids");

if (uuids && uuids.length>0) {
postman.setNextRequest(myurl/?userid={{uuid}});
} else {
postman.setNextRequest();
}

我查看了有关文档的内容,但找不到我的代码有什么问题。

I have looked over regarding documentation and I cannot find what is wrong with my code.

谢谢!

推荐答案

预请求脚本不是用不同数据测试api的好方法。

Pre-request script is not a good way to test api with different data. Better use Postman runner for the same.

首先,准备带有可变数据的邮递员的请求。例如

First, prepare a request with postman with variable data. For e.g

然后单击运行器选项卡

使用数据准备csv文件

Prepare csv file with data

uuids
1eb253c6-8784
d3fb3ab3-4c57
d3fb3ab3-4c78

并提供为数据文件,并运行示例。

And provide as data file, and run the sample.

它将允许您使用不同的数据类型多次运行相同的api,并可以检查测试用例。

It will allow you run the same api, multiple times with different data types and can check test cases.

这篇关于使用不同的数据多次在Postman中运行请求仅运行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆