【发布时间】:2020-05-20 06:12:34
【问题描述】:
我在邮递员中有一个包含很多请求的集合,Newman 中是否有任何选项可以运行来自该集合的特定请求,而不是为特定请求创建新文件夹并运行
【问题讨论】:
-
这是
newman's GitHub repo 上的一个附属问题:github.com/postmanlabs/newman/issues/276
标签: api collections postman newman runner
我在邮递员中有一个包含很多请求的集合,Newman 中是否有任何选项可以运行来自该集合的特定请求,而不是为特定请求创建新文件夹并运行
【问题讨论】:
newman's GitHub repo 上的一个附属问题:github.com/postmanlabs/newman/issues/276
标签: api collections postman newman runner
不,不可能使用 newman 从集合中运行单个请求。 参考newman command line options
【讨论】:
是的,您可以使用选项--folder 在 newman CLI 的集合运行程序中运行特定请求。
文档:
CLI 选项:--文件夹“名称”
在特定文件夹中运行请求或在集合中运行特定请求。可以多次使用 --folder 指定多个文件夹或请求,如下所示:--folder f1 --folder f2 --folder r1 --folder r2。
例子:
newman run "postman-collection-API" --environment "postman-environment-API" --folder request-name
【讨论】:
--folder 支持似乎是 v4 的新增功能顺便说一句:stackoverflow.com/questions/52519415/…
你也可以在 newman 库中运行特定的请求,如下:
文档:
options.folder- 集合中将运行而不是整个集合的文件夹/文件夹 (ItemGroup) 的名称或 ID。
例子:
newman.run(
{
collection: 'postman-collection-API',
environment: 'postman-environment-API',
folder: ['request-name', 'other-request-name']
},
function (error, summary) {
console.log(`${summary.run.executions.length} requests were run`);
}
);
【讨论】: