【问题标题】:how to run single request from the collection in newman如何从 newman 的集合中运行单个请求
【发布时间】:2020-05-20 06:12:34
【问题描述】:

我在邮递员中有一个包含很多请求的集合,Newman 中是否有任何选项可以运行来自该集合的特定请求,而不是为特定请求创建新文件夹并运行

【问题讨论】:

标签: api collections postman newman runner


【解决方案1】:

不,不可能使用 newman 从集合中运行单个请求。 参考newman command line options

【讨论】:

    【解决方案2】:

    是的,您可以使用选项--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
    

    【讨论】:

    【解决方案3】:

    你也可以在 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`);
      }
    );
    

    【讨论】:

      猜你喜欢
      • 2018-09-20
      • 2017-11-03
      • 2018-05-26
      • 2019-07-18
      • 2020-11-24
      • 2019-12-14
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      相关资源
      最近更新 更多