WINDOWS下NEWMAN的安装与使用
安装
官方文档:
Newman - Runningcollections in the command line
1. 安装NodeJs
下载 NodeJs. 到下载地址下载 合适版本的node.exe即可。
下载地址: https://nodejs.org/download/
打开cmd,输入node,如果没有报错,而是显示“>”,说明node安装成功。
备注:安装方法可以参考 深入浅出Node.js(二):Node.js&NPM的安装与配置
2. 安装NPM
NPM是NodeJs的包管理器,类似于python的setuptools。(一般在安装完node.js之后,npm也会同样安装)
下载NPM:git clone–recursive git://github.com/isaacs/npm.git
进入到npm文件夹,然后打开cmd。
在cmd中执行:node cli.jsinstall npm –gf
然后再任意地方,打开cmd,输入“npm”,没有报错说明NPM安装成功。
备注: 可以参考 深入浅出Node.js(二):Node.js&NPM的安装与配置
3. 安装Newman
打开cmd,输入: npm install-g newman
4. 使用newman
打开cmd,然后输入 “newman”,没有报错说明安装成功。
使用
可以参考:
Newman - Runningcollections in the command line
1. 执行 collection。
newman run {json filesource}//绝对路径比较准确
//(Windows系统后面不需要分号,linux系统需要) 暂时是这样,准确性有待验证
例如:newman run C:\Users\xingzheng\Desktop\dafmng-api.json
2. 直接发送一个request。
表示URL为“
https://www.getpostman.com/collections/cb208e7e64056f5294e5", Environment 为“dev_environment.json”。
newman run https://www.getpostman.com/collections/cb208e7e64056f5294e5--environment dev_environment.json
3. 设置跑测试的轮数。
表示跑10轮测试。
newman run C:\Users\xingzheng\Desktop\dafmng-api.json -n 10
4. 设置数据文件。
newman run collection.json --environment env.json --iteration-data data.csv --globals globals.json --iteration-count 2 --export-globals globalOut.json --export-environment envOut.json --delay-request 10 --timeout-request 5000 --disable-unicode --suppress-exit-code --ignore-redirects --bail
5. 保存output到文件。
newman run https://a.com/collection.json --environment https://a.com/env.json --reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml --reporter-html-export htmlOutput.htm
WINDOWS下NEWMAN的安装与使用
安装
官方文档:
Newman - Runningcollections in the command line
1. 安装NodeJs
下载 NodeJs. 到下载地址下载 合适版本的node.exe即可。
下载地址: https://nodejs.org/download/
打开cmd,输入node,如果没有报错,而是显示“>”,说明node安装成功。
备注:安装方法可以参考 深入浅出Node.js(二):Node.js&NPM的安装与配置
2. 安装NPM
NPM是NodeJs的包管理器,类似于python的setuptools。(一般在安装完node.js之后,npm也会同样安装)
下载NPM:git clone–recursive git://github.com/isaacs/npm.git
进入到npm文件夹,然后打开cmd。
在cmd中执行:node cli.jsinstall npm –gf
然后再任意地方,打开cmd,输入“npm”,没有报错说明NPM安装成功。
备注: 可以参考 深入浅出Node.js(二):Node.js&NPM的安装与配置
3. 安装Newman
打开cmd,输入: npm install-g newman
4. 使用newman
打开cmd,然后输入 “newman”,没有报错说明安装成功。
使用
可以参考:
Newman - Runningcollections in the command line
1. 执行 collection。
newman run {json filesource}//绝对路径比较准确
//(Windows系统后面不需要分号,linux系统需要) 暂时是这样,准确性有待验证
例如:newman run C:\Users\xingzheng\Desktop\dafmng-api.json
2. 直接发送一个request。
表示URL为“
https://www.getpostman.com/collections/cb208e7e64056f5294e5", Environment 为“dev_environment.json”。
newman run https://www.getpostman.com/collections/cb208e7e64056f5294e5--environment dev_environment.json
3. 设置跑测试的轮数。
表示跑10轮测试。
newman run C:\Users\xingzheng\Desktop\dafmng-api.json -n 10
4. 设置数据文件。
newman run collection.json --environment env.json --iteration-data data.csv --globals globals.json --iteration-count 2 --export-globals globalOut.json --export-environment envOut.json --delay-request 10 --timeout-request 5000 --disable-unicode --suppress-exit-code --ignore-redirects --bail
5. 保存output到文件。
newman run https://a.com/collection.json --environment https://a.com/env.json --reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml --reporter-html-export htmlOutput.htm