[root@localhost bin]# newman run -h Usage: run <collection> [options] URL or path to a Postman Collection. Options: -e, --environment <path> Specify a URL or Path to a Postman Environment. -g, --globals <path> Specify a URL or Path to a file containing Postman Globals. --folder <path> Specify folder to run from a collection. Can be specified multiple times to run multiple folders (default: []) -r, --reporters [reporters] Specify the reporters to use for this run. (default: ["cli"]) -n, --iteration-count <n> Define the number of iterations to run. -d, --iteration-data <path> Specify a data file to use for iterations (either json or csv). --export-environment <path> Exports the environment to a file after completing the run. --export-globals <path> Specify an output file to dump Globals before exiting. --export-collection <path> Specify an output file to save the executed collection --postman-api-key <apiKey> API Key used to load the resources from the Postman API. --delay-request [n] Specify the extent of delay between requests (milliseconds) (default: 0) --bail [modifiers] Specify whether or not to gracefully stop a collection run on encountering an errorand whether to end the run with an error based on the optional modifier. -x , --suppress-exit-code Specify whether or not to override the default exit code for the current run. --silent Prevents newman from showing output to CLI. --disable-unicode Forces unicode compliant symbols to be replaced by their plain text equivalents --global-var <value> Allows the specification of global variables via the command line, in a key=value format (default: []) --color <value> Enable/Disable colored output. (auto|on|off) (default: "auto") --timeout [n] Specify a timeout for collection run (in milliseconds) (default: 0) --timeout-request [n] Specify a timeout for requests (in milliseconds). (default: 0) --timeout-script [n] Specify a timeout for script (in milliseconds). (default: 0) --ignore-redirects If present, Newman will not follow HTTP Redirects. -k, --insecure Disables SSL validations. --ssl-client-cert <path> Specify the path to the Client SSL certificate. Supports .cert and .pfx files. --ssl-client-key <path> Specify the path to the Client SSL key (not needed for .pfx files) --ssl-client-passphrase <path> Specify the Client SSL passphrase (optional, needed for passphrase protected keys). -h, --help output usage information <collection>是指单个请求或者从postman导出的集合文件(也就是json格式的脚本) options是一些组合参数,介绍下我用到的几个参数 (1) -e 指定环境变量,把在postman中设置的环境变量导出,然后再把路径填写到这里即可 (2) -g 指定全局变量,把在postman中设置的全局变量导出,然后再把路径填写到这里即可 (3) -n 指定迭代次数,即运行n次脚本 (4) --timeout-request 指定请求的超时时间 (5) -r 指定运行报告的格式,可以为json格式、html格式,默认为cli格式,即在命令行展示运行结果实例1: 把接口测试脚本和环境变量脚本导出放到一个目录中,在cmd窗口中切换到该目录,执行如下命令 E:\5.coding\postman>newman run Test.postman_collection.json -n 2 -e base_url.postman_environment.json Test.postman_collection.json -- 接口测试脚本文件 base_url.postman_environment.json -- 环境变量文件 -n 2表示迭代2次 执行过程如下 执行完成后,会出现一个类似报表的东西,显示整体运行结果 实例2: E:\5.coding\postman>newman run Test.postman_collection.json -e base_url.postman_environment.json --reporters cli,json,html --reporter-json-export report-json.json --reporter-html-export report-html.html --reporters cli,json,html --reporter-json-export report-json.json --reporter-html-export report-html.html 表示生成json和html格式的报告 html格式的报告长下面这个样子,还是蛮难看的。