【接口测试】1_Postman _Postman环境搭建 - 指南

一、简介

Postman是一款非常流行的接口调试工具,它使用简单,而且功能也很强大。不仅测试人员会使用,开发人员也会经常使用。

官方网址:https://www.postman.com/

主要特点:

  1. 简单易用的图形用户界面
  2. 可以保存接口请求的历史记录
  3. 使用测试集Collections可以更有效的管理组织接口
  4. 可以在团队之间同步接口数据

二、Postman安装和插件newman

2.1 Postman安装

2.1.1 Postman安装方式

方式1:

  • Postman最早是以Chrome浏览器插件的形式存在的,可以到chrome商店搜索下载安装。由于2018年初Chrome停止对Chrome应用程序的支持,所以不再推荐使用该方式。

方式2:

  • Postman提供了独立的安装包,不再依赖于Chrome浏览器了。同时支持MAC、Windows和Linux,推荐使用这种方式安装。
  • 下载地址:https://www.postman.com/apps

2.1.2 Postman注意事项

  • 一旦安装成功,尽量坚持使用不要卸载!
  • Postman有个BUG,不能重复安装,如果重复安装,新安装的版本 必须 大于已安装的版本。

2.2 安装Postman插件newman

要想给Postman安装插件newman,必须安装 node.js 。

2.2.1 安装node.js

1、下载安装 node.js:https://nodejs.org/zh-cn/download/package-manager

2、验证:使用 win+r,输 cmd 打开终端,输入命令 npm -v,如能显示版本号(版本略有差异无所谓)。代表 node.js 安装成功。

C:\Users\ggk>npm -v
6.14.4

2.2.2 安装newman (前提:确保 npm -v 验证通过)

1、安装newman时,必须保证 node.js 已经装成功!

2、在线安装和验证命令:

# 1、安装命令(使用管理员身份启动终端,写入命令)
C:\Users\ggk>npm install -g newman
# 2、验证安装
C:\Users\ggk>newman -v
5.2.2
2.2.2.1 npm install报错ERR code ETIMEDOUT的解决办法
# 1. 清空缓存
npm cache clean --force
# 2. 切换新源
npm config set registry https://registry.npmmirror.com
# 3. 查看源是否设置成功
npm config get registry
# 4. 可以正常安装需要的工具了
npm insatll xxx
2.2.2.2 安装newman显示required node version >=16解决办法
# 验证安装
C:\Users\ggk>newman -v
newman: required node version >=16
-----------------------------------------------------------------
# 解决办法,直接安装对应版本就行。
C:\Users\ggk>npm install -g newman@5.2.2
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
C:\Users\ggk\AppData\Roaming\npm\newman -> C:\Users\ggk\AppData\Roaming\npm\node_modules\newman\bin\newman.js
+ newman@5.2.2
added 54 packages from 53 contributors, removed 14 packages and updated 31 packages in 24.125s
C:\Users\ggk>newman -v
5.2.2

2.3 安装newman-reporter-htmlextra

# 安装命令
C:\Users\ggk>npm install -g newman-reporter-htmlextra
npm WARN newman-reporter-htmlextra@1.0.5 requires a peer of newman@4 but none is installed. You must install peer dependencies yourself.
# 看下面类似信息,代表安装完成。
+ newman-reporter-htmlextra@1.0.5
added 12 packages from 44 contributors in 3.873s
————————————————————————————————————————————————————————————————————————————
注意:有的电脑不支持,可以安装:newman-reporter-html
posted on 2026-01-29 10:43  ljbguanli  阅读(0)  评论(0)    收藏  举报