newman run /Users/wanghuan/07-postman/02-test/04.postman_collection.json -e /Users/wanghuan/07-postman/02-test/url.postman_environment.json --bail --verbose
1、
--bail当测试用例失败时停止运行器
2、--verbose
1)环境变量:如果有固定值且不变,可直接写到环境变量中(其他方法不知道);其次,不要把tests里的传递变量写到环境变量里,因为newman运行时无法识别
2)全局变量:newman可以识别
3)集合变量:newman支持集合中接口之间传递变量参数;
其使用方法为pm.collectionVariables.set方法保存到集合中,并用pm.collectionVariables.get读取值;
把接口之间传递变量写到环境变量中时,如图
newman run /Users/wanghuan/07-postman/02-test/04.postman_collection.json -e /Users/wanghuan/07-postman/02-test/url.postman_environment.json --bail newman
newman
把接口之间传递变量写到集合中时,如图
newman run /Users/wanghuan/07-postman/02-test/04.json -e /Users/wanghuan/07-postman/02-test/03url.environment.json --bail
newman run 用例名称 [-e | -r | -d | -g -n - export-environment | -timeout (ms) | -timeport-request (ms) | -timeout-script (ms)]
-e等同于--environment:后面跟环境变量文件
-g等同于--globals:后面跟全局变量文件
-n等同于--iteration-count:设置迭代次数 postman参数化迭代测试
-d等同于--iteration-data:指定用于迭代的数据源文件(json,cvs)
-r等同于--reporters:后面跟数据结果,可以跟cli、html、json等
cli:直接在命令行打印结果
html:将结果生成为html文件,指定生成到具体目录需要配合--reporter-html-export 文件名使用
json:将结果生成为json文件,指定生成到具体目录需要配合--reporter-json-export 文件名使用
# -timeout (ms) 设置整个集合运行完成执行的时间
# –timeport-request (ms) 指定等待请求返回响应的时间
# -timeout-script (ms)指定等待脚本执行完成的时间
# --folder 运行collection中的指定folder
# --reporters html,json,junit 指定生成报告的类型
官方的文档介绍如下:https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/
运行参数化:PostMan-NewMan运行参数 - happyyangyanghappy - 博客园原地址链接:https://brucelong.blog.csdn.net/article/details/89707536 PostMan-NewMan运行参数(二)一、Newman参数查看 1、在https://www.cnblogs.com/happyyangyanghappy/p/15016466.html