跳到主要内容

Postman Runtime library

Postman Runtime 库支持在 Postman 以及其他界面(包括 Newman ,Postman 的命令行 collection run 器)中 运行请求发送和收集。

该库是一个 开源 Node.js 项目, 可用于在 API 开发和测试项目中通过请求发送进行低级配置。

要开始使用运行时库,请查看存储库的 自述文件

你可以从 npm 安装库。 以下示例代码显示了将运行时库与 Collection SDK 结合使用的简化概要:

runtime = require('postman-runtime');
var runner = new runtime.Runner();

//Collection object constructed using the 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 ,Postman 的命令行工具。

下一步

现在你已经开始使用运行时库,你可能还想在持续集成和持续部署 (CI/CD) 工作流中使用 Postman API:

  • 要了解有关将 Postman 整合到你的 CI/CD 工作流中的更多信息,请访问 CI with Postman API