【发布时间】:2016-07-09 12:00:43
【问题描述】:
我想发布来自 Postman Google Chrome 扩展程序的数据。
我想用不同的数据发出 10 个请求,而且应该同时进行。
在 Postman 中可以这样做吗?
如果是,谁能向我解释如何实现?
【问题讨论】:
-
打开请求的文件夹并点击运行,您将看到一个选择迭代次数的选项:)
标签: post postman httprequest
我想发布来自 Postman Google Chrome 扩展程序的数据。
我想用不同的数据发出 10 个请求,而且应该同时进行。
在 Postman 中可以这样做吗?
如果是,谁能向我解释如何实现?
【问题讨论】:
标签: post postman httprequest
我猜邮递员没有运行并发测试这样的功能。
如果我是你,我会考虑Apache jMeter,它正好用于此类场景。
关于 Postman,唯一能或多或少满足您需求的是 - Postman Runner。 您可以在此处指定详细信息:
运行不会并发,只会连续运行。
希望对您有所帮助。但是请考虑使用 jMeter(你会喜欢它的)。
【讨论】:
Postman 不这样做,但您可以在 Bash 中异步运行多个 curl 请求:
curl url1 & curl url2 & curl url3 & ...
记得在每个请求之后添加&,这意味着请求应该作为异步作业运行。
但是,Postman 可以为您的请求生成 curl sn-p:https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/
【讨论】:
我不知道这个问题是否仍然相关,但现在 Postman 有这种可能性。他们在几个月前添加了它。
您只需要创建简单的 .js 文件并通过 node.js 运行它。它看起来像这样:
var path = require('path'),
async = require('async'), //https://www.npmjs.com/package/async
newman = require('newman'),
parametersForTestRun = {
collection: path.join(__dirname, 'postman_collection.json'), // your collection
environment: path.join(__dirname, 'postman_environment.json'), //your env
};
parallelCollectionRun = function(done) {
newman.run(parametersForTestRun, done);
};
// Runs the Postman sample collection thrice, in parallel.
async.parallel([
parallelCollectionRun,
parallelCollectionRun,
parallelCollectionRun
],
function(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.`);
});
});
然后运行这个 .js 文件(cmd 中的'node fileName.js')。
更多详情here
【讨论】:
不确定人们是否仍在寻找简单的解决方案,但您可以在 Postman 中运行“Collection Runner”的多个实例。只需创建一个带有一些请求的运行器,然后多次单击“运行”按钮即可调出多个实例。
【讨论】:
并行运行一个文件夹中的所有集合:
'use strict';
global.Promise = require('bluebird');
const path = require('path');
const newman = Promise.promisifyAll(require('newman'));
const fs = Promise.promisifyAll(require('fs'));
const environment = 'postman_environment.json';
const FOLDER = path.join(__dirname, 'Collections_Folder');
let files = fs.readdirSync(FOLDER);
files = files.map(file=> path.join(FOLDER, file))
console.log(files);
Promise.map(files, file => {
return newman.runAsync({
collection: file, // your collection
environment: path.join(__dirname, environment), //your env
reporters: ['cli']
});
}, {
concurrency: 2
});
【讨论】:
在邮递员的收集运行器中,您不能同时发出异步请求,因此请改用Apache JMeter。它允许您添加多个线程并为其添加同步计时器
【讨论】:
如果您只执行 GET 请求,并且需要在 Chrome 浏览器中使用另一个简单的解决方案,只需安装“打开多个 URL”扩展程序:
https://chrome.google.com/webstore/detail/open-multiple-urls/oifijhaokejakekmnjmphonojcfkpbbh?hl=en
我一次只运行了 1500 个 url,确实有点落后于谷歌,但它确实有效。
【讨论】:
最简单的方法是获取 => Google Chrome "TALEND API TESTER" 转到帮助 + 输入创建场景 ...或者直接访问此链接 => https://help.talend.com/r/en-US/Cloud/api-tester-user-guide/creating-scenario
我能够同时发送多个 POST API 调用。
【讨论】:
为什么只将 Postman 用于此目的? 您可以使用任何语言 pythong、javascript 等编写脚本。 Python 为我做到了这一点
【讨论】: