如何多次运行单个端点? [英] How can I run a single endpoint multiple times?

查看:12
本文介绍了如何多次运行单个端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含三个端点的集合.第一个创建资产,第二个将文件添加到资产,第三个列出所有资产.

I have a Collection that has three endpoints. The first one creates an asset, the second one adds a file to the asset, and the third one lists all the assets.

如何在 Runner 的每次迭代中多次运行第二个,即向资产添加文件的那个?

How can I run the second one, the one that adds a file to the asset, more than once per each iteration of the Runner?

我希望测试创建一个资产并为每次迭代添加多个文件.

I'd like the test to create an asset and add multiple files to it for each iteration.

有什么建议吗?我知道我可以复制端点,但我想知道是否有一种编程方式来做到这一点.

Any suggestions? I know I can duplicate the endpoint, but I was wondering if there was a programmatic way to do it.

推荐答案

到目前为止,还没有直接的解决方案使用 Postman 来为文件夹/集合中的同一请求配置多个命中.

So far, there is no straight forward solution using Postman, to configure several hits for the same request within a folder/collection.

不过,您可以在 预请求脚本 部分编写一些代码,方法是添加计数器与您想要的点击次数并调用 postman.setNextRequest("request_name") 方法(这里)与您当前的请求.

Nevertheless, you can write some code in Pre-request script section, by adding a counter with number of hits you want and call postman.setNextRequest("request_name") method (read more about it from here) with you current request.

在 Postman 应用程序范围之外,您可以导出您的集合(作为 JSON 文件)并使用 newman 编写一些 JavaScript 代码,它是 Postman 的命令行配套实用程序(更多关于 newman 的信息来自 here)获得 run 方法具有大量迭代计数和数据选项,可以帮助您(例如,将您的第二个请求放入文件夹并遍历它).

Out of Postman app scope, you can export your collection (as JSON file) and write some javascript code using newman which is a Command-line companion utility for Postman (more about newman from here) which gets a run method with a lot of iteration count and data options that would help you (for example, putting your second request in folder and iterates through it).

希望有帮助!

这篇关于如何多次运行单个端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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