postman-Newman的安装及使用


安装

官方文档:

Newman - Running collections in the command line

Installing Newman on Windows

 

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.js install npm –gf

然后再任意地方,打开cmd,输入“npm”,没有报错说明NPM安装成功。


备注: 可以参考 深入浅出Node.js(二):Node.js&NPM的安装与配置

 

3. 安装Newman

打开cmd,输入: npm install -g newman

 

4. 使用newman

打开cmd,然后输入 “newman”,没有报错说明安装成功。


使用

可以参考:

Newman - Running collections in the command line

newman 官方文档

newman github

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




 Newman V2与V3的区别之处

CLI migration table
V2 CLI optionV3 equivalentV2 option Status
-c --collectionN.ADeprecated (Pass the collection file path without the collection flag)
-u --urlN.ADeprecated (Pass the collection file URL without the collection flag)
--environment-urlN.ADeprecated (Pass the environment file URL to -e --environment)
-f --folder--folderDeprecated. The V3 folder option has been reduced to --folder
-d --data-d --iteration-dataDeprecated
-n --number-n --iteration-countDeprecated
-i --importN.ADeprecated
-p --prettyN.ADiscontinued
-G --exportGlobals--export-globalsDeprecated
-E --exportEnvironment--export-environmentDeprecated
-y --delay--delay-requestDeprecated
-r --requestTimeout--timeout-requestDeprecated
-s --stopOnError--bailDeprecated
-j --noSummary--reporter-cli-no-summaryDeprecated
-C --noColour--no-colorDeprecated
-S --noTestSymbols--disable-unicodeDiscontinued
-l --tlsN.ADiscontinued
-x --exitCode-x --suppress-exit-codeDeprecated
-w --whiteScreenN.ADiscontinued
-o --outputFile--reporter-json-exportDeprecated
-t --testReportFile--reporter-junit-exportDeprecated
-H --html--reporter-html-exportDeprecated
-O --outputFileVerboseN.ADiscontinued
-R --avoidRedirects--ignore-redirectsDeprecated

NewmanV3命令说明:

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值