首页 > 解决方案 > 在邮递员中组合多个集合

问题描述

我正在尝试在詹金斯一次运行多个邮递员收藏

下面是我的场景 collection1.json,其中 data1.csv 和环境变量为 environment1.json collection1.json 与 data1.csv 和环境变量为 environment1.json

我想一次性运行上面的集合 - 请让我知道如何组合 2 个集合并一次运行?- 有没有办法一次下载邮递员中的每个集合而不是一个一个地下载?-使用邮递员收集组合的示例

标签: postman-collection-runner

解决方案


我知道 Postman collection runner 有一些限制,但我能够使用这篇文章实现它

这是允许您并行运行多个 Postman 集合的脚本:

const path = require('path')
const async = require('async')
const newman = require('newman')

const PARALLEL_RUN_COUNT = 2

const parametersForTestRun = {
    collection: path.join(__dirname, 'postman/postman_collection.json'), // your collection
    environment: path.join(__dirname, 'postman/localhost.postman_environment.json'), //your env
    reporters: 'cli'
};

parallelCollectionRun = function (done) {
    newman.run(parametersForTestRun, done);
};

let commands = []
for (let index = 0; index < PARALLEL_RUN_COUNT; index++) {
    commands.push(parallelCollectionRun);
}

// Runs the Postman sample collection thrice, in parallel.
async.parallel(
    commands,
    (err, results) => {
        err && console.error(err);

        results.forEach(function (result) {
            var failures = result.run.failures;
            console.info(failures.length ? JSON.stringify(failures.failures, null, 2) :
                `${result.collection.name} ran successfully.`);
        });
    });

推荐阅读