Postman 运行时库
Postman Runtime 库支持在 Postman 应用程序以及包括 Newman CLI 在内的其他接口中运行的请求发送和收集。
该库是一个开源 Node.js 项目,您可以在 API 开发和测试项目中通过请求发送进行低级配置。
您可以从npm安装库。以下示例代码显示了将 Runtime 库与Collection SDK结合使用的简化大纲:
runtime = require('postman-runtime');
var runner = new runtime.Runner();
//Collection object constructed via Collection SDK
var collection = new sdk.Collection();
runner.run(collection, {
data: [],
timeout: {
request: 30000,
script: 5000
},
iterationCount: 1,
//other options...
},
function (err, run) {
//Callbacks to execute as the collection runs
run.start(callbacks);
});
如果您需要详细配置请求运行,您可以使用运行时库,例如作为自动化工作流程的一部分,将 Postman Collection 运行集成到您的开发管道中。
请注意,如果您只需要运行集合,则可以使用Newman CLI。
下一步
要开始使用运行时库,请查看 repo README。您可以使用 Postman API 通过 CI将 Postman 整合到您的工作流程中。