【问题标题】:Combining multiple collections in postman在邮递员中组合多个集合
【发布时间】:2020-03-10 19:53:30
【问题描述】:

我正在尝试在 jenkins 中一次运行多个邮递员集合

以下是我的场景 collection1.json 与 data1.csv 和环境变量作为 environment1.json collection1.json 与 data1.csv 和环境变量作为 environment1.json

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

【问题讨论】:

    标签: postman-collection-runner


    【解决方案1】:

    我知道 Postman 收集运行器有一些限制,但我能够使用 this article 实现它

    这是让您并行运行多个 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.`);
            });
        });
    

    【讨论】:

    • 欢迎提供解决方案链接,但请确保您的答案在没有它的情况下有用:add context around the link 这样您的其他用户就会知道它是什么以及为什么会出现,然后引用最相关的您链接到的页面的一部分,以防目标页面不可用。 Answers that are little more than a link may be deleted.
    • @Dharman 好的,我明白了。我已经添加了文章中的脚本。
    猜你喜欢
    • 2019-10-08
    • 2019-12-14
    • 2020-01-04
    • 2019-05-13
    • 1970-01-01
    • 2020-05-10
    • 2017-04-14
    • 2023-04-02
    • 1970-01-01
    相关资源
    最近更新 更多