运行集合
右键collection点击run collection进入RUNNER设置(前置条件:每个请求都完成了test script的编写)
配置完成后点击运行即可
如果需要上一个接口的返回值作为当前接口的入参,则可取对应返回值设置为变量,并在当前接口使用该变量作为入参即可。
另,除了可以手动拖动request选择运行顺序外,也可以通过以下语法设置下一个运行的request
postman.setNextRequest("request_name");
停止工作流的执行
postman.setNextRequest(null);
注:无论setNextRequest写在pre-request script还是test script,都会在当前request完成后执行。
监控定时运行
选择Monitors点击+可以设置定时任务
Newman使用命令行运行
第一步:下载newman
$ npm install -g newman
没有npm先下载Node.js
第二步:运行集合
下载集合后直接运行
$ newman run /Users/liuyan/Desktop/collection.json
使用集合分享链接运行
$ newman run https://assets.postman.com/postman-docs/58533790.json
使用-h可以查看所有newman选项
$ newman run -h
例如设置迭代次数等
$ newman run mycollection.json -n 10 # runs the collection 10 times
jenkins持续集成
下载newman及对应集合,Build选择Execute shell后输入newman命令即可,例
$ newman run /path/to/jenkins_demo.postman_collection.json --suppress-exit-code 1
其余设置均在jenkins直接设置即可。