邮递员:如何同时发出多个请求
Postman: How to make multiple requests at the same time
我想 POST 来自 Postman Google Chrome 扩展程序的数据。
我想用不同的数据发出 10 个请求,并且应该同时发出。
在 Postman 中可以这样做吗?
如果是,谁能向我解释一下这是如何实现的?
我想 postman 中没有 运行 并发测试的功能。
如果我是你,我会考虑Apache jMeter,正好适合这种场景
关于Postman,唯一能或多或少满足你需求的就是——Postman Runner。
您可以在此处指定详细信息:
- 迭代次数,
- 上传包含不同测试 运行s 等数据的 CSV 文件
运行不会并发,只会连续。
希望对您有所帮助。但一定要考虑 jMeter(您会爱上它)。
我不知道这个问题是否仍然相关,但现在 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 文件('node fileName.js' in cmd)。
更多详情here
Postman 不会那样做,但您可以 运行 多个 curl
异步请求 Bash:
curl url1 & curl url2 & curl url3 & ...
请记住在每个请求后添加一个 &
,这意味着该请求应 运行 作为异步作业。
然而,Postman 可以为您的请求生成 curl 片段:https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/
运行 并行文件夹中的所有集合:
'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
});
在 postman 的 collection runner 中,您不能同时发出异步请求,因此请改用 Apache JMeter。它允许您添加多个线程并为其添加同步计时器
不确定人们是否仍在寻找简单的解决方案,但您可以在 Postman 中 运行 "Collection Runner" 的多个实例。只需创建一个包含一些请求的 运行ner,然后多次单击 "Run" 按钮即可调出多个实例。
如果您只执行 GET 请求并且需要在 Chrome 浏览器中使用另一个简单的解决方案,只需安装 "Open Multiple URLs" 扩展程序:
https://chrome.google.com/webstore/detail/open-multiple-urls/oifijhaokejakekmnjmphonojcfkpbbh?hl=en
我一次 运行 1500 url,确实有点滞后 google 但它有效。
最简单的方法是获取 => Google Chrome "TALEND API TESTER"
转到帮助 + 输入创建场景
...或者直接转到 link => https://help.talend.com/r/en-US/Cloud/api-tester-user-guide/creating-scenario
我能够同时发送多个 POST API 电话。
您可以 运行 postman Runner 的多个实例和 运行 在每个实例中具有不同数据文件的同一集合。
我想 POST 来自 Postman Google Chrome 扩展程序的数据。
我想用不同的数据发出 10 个请求,并且应该同时发出。
在 Postman 中可以这样做吗?
如果是,谁能向我解释一下这是如何实现的?
我想 postman 中没有 运行 并发测试的功能。
如果我是你,我会考虑Apache jMeter,正好适合这种场景
关于Postman,唯一能或多或少满足你需求的就是——Postman Runner。
- 迭代次数,
- 上传包含不同测试 运行s 等数据的 CSV 文件
运行不会并发,只会连续。
希望对您有所帮助。但一定要考虑 jMeter(您会爱上它)。
我不知道这个问题是否仍然相关,但现在 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 文件('node fileName.js' in cmd)。
更多详情here
Postman 不会那样做,但您可以 运行 多个 curl
异步请求 Bash:
curl url1 & curl url2 & curl url3 & ...
请记住在每个请求后添加一个 &
,这意味着该请求应 运行 作为异步作业。
然而,Postman 可以为您的请求生成 curl 片段:https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/
运行 并行文件夹中的所有集合:
'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
});
在 postman 的 collection runner 中,您不能同时发出异步请求,因此请改用 Apache JMeter。它允许您添加多个线程并为其添加同步计时器
不确定人们是否仍在寻找简单的解决方案,但您可以在 Postman 中 运行 "Collection Runner" 的多个实例。只需创建一个包含一些请求的 运行ner,然后多次单击 "Run" 按钮即可调出多个实例。
如果您只执行 GET 请求并且需要在 Chrome 浏览器中使用另一个简单的解决方案,只需安装 "Open Multiple URLs" 扩展程序:
https://chrome.google.com/webstore/detail/open-multiple-urls/oifijhaokejakekmnjmphonojcfkpbbh?hl=en
我一次 运行 1500 url,确实有点滞后 google 但它有效。
最简单的方法是获取 => Google Chrome "TALEND API TESTER" 转到帮助 + 输入创建场景 ...或者直接转到 link => https://help.talend.com/r/en-US/Cloud/api-tester-user-guide/creating-scenario
我能够同时发送多个 POST API 电话。
您可以 运行 postman Runner 的多个实例和 运行 在每个实例中具有不同数据文件的同一集合。