Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.npm
Newman是Postman的命令行收集运行程序。它使您能够直接从命令行轻松地运行和测试Postman集合。它在构建时考虑了可扩展性,所以您能够轻松地将其与持续集成服务器集成并构建系统。json
要运行Newman,请确保您具备Node.js> = v10。segmentfault
1.安装Newman的最简单方法是使用NPM。若是安装了Node.js,则极可能也安装了NPM。服务器
npm install -g newman
这会将Newman全局安装在您的系统上,从而使您能够从任何地方运行它。若是要在本地安装,只需删除该-g标志。less
2.也能够经过yum安装post
yum install -y newman
该newman run命令容许您指定要运行的集合。您能够轻松地从Postman App中将Postman Collection导出为json文件,并使用Newman运行它。测试
newman run examples/sample-collection.json
若是您的收集文件能够做为URL使用(例如从咱们的Cloud API服务),Newman能够获取您的文件并运行它。ui
newman run https://www.getpostman.com/collections/631643-f695cab7-6878-eb55-7943-ad88e1ccfd65-JsLv
·-h,--help 显示命令行帮助(包括选项列表)和示例用例。
·-v,--version 显示当前的Newman版本
·newman run <collection-file-source> [options] -e <source>,--environment <source> 指定环境文件路径或URL。环境提供了一组能够在集合中使用的变量。
-g <source>,--globals <source> 为全局变量指定文件路径或URL。全局变量与环境变量类似,可是优先级较低,而且能够被具备相同名称的环境变量覆盖。
-d ,--iteration-data 指定要用于迭代的数据源文件(JSON或CSV)做为文件路径或URL。
-n ,--iteration-count 指定与迭代数据文件一块儿使用时必须运行集合的次数。
首先要保证手动点击collections执行成功url
newman run admin登陆接口+建立主机测试.postman_collection.json -e ip.postman_environment.json -d admin登陆+添加主机测试数据_.json
如下是咱们执行命令的结果,能够看到测试结果所有成功了。
更多功能参考官网:https://www.npmjs.com/package...spa