纽曼帮助指定可以将收集,环境和全球群体作为路径或URL传递。我可以看到如何从Postman获得收集URL(通过共享> Collection链接)。
我如何将URL到邮递员的环境和全球范围,以便我可以将它们传递给纽曼?
使用纽曼与Postman Pro API:
- 生成一个API键
- 从以下方式获取您的收藏清单:
https://api.getpostman.com/collections?apikey=$apiKey
- 通过其UID获取集合链接:
https://api.getpostman.com/collections/$uid?apikey=$apiKey
- 从:
https://api.getpostman.com/environments?apikey=$apiKey
- 使用步骤3和4中获得的uris收集和环境,如下以下集合:
newman run "https://api.getpostman.com/collections/$uid?apikey=$apiKey" --environment "https://api.getpostman.com/environments/$uid?apikey=$apiKey"
链接到纽曼软件包
使用Postman桌面应用程序,请尝试以下步骤 -
- 在Postman中查看您的收藏
- 从收集详细信息查看(按集合名称旁边的箭头),然后选择
View in Web
。 - 在Postman Web视图中,在右侧的Postman徽标旁边,有一个下拉。
- 从下拉菜单中选择 workspace 您的测试集合在哪里。
- 在"集合列表"页面上,您将看到 vromentments 作为集合旁边的选项卡。
- 选择"环境"选项卡,然后选择所需的特定环境。
- 此页面上的URL是您可以用于Postman的环境URL。
通过Postman,我将环境作为JSON文件导出,然后在Web服务器上托管了该文件。
我没有得到如何让Postman Globals URL传递给Newman?我只能获得收集和环境URL。
从命令行,使用newman命令行选项:
-e <source>, --environment <source>
Specify an environment file path or URL. Environments provide a set
of variables that one can use within collections. Read More
-g <source>, --globals <source>
Specify file path or URL for global variables. Global variables are
similar to environment variables but has a lower precedence and can
be overridden by environment variables having same name.
如果您将纽曼用作节点JS模块,请为Newman.run()提供环境和全局作为选项:
newman.run({environment: <source>, globals: <source>}, callback)