Postman在CentOS上的“插件”安裝說明
Postman作為API開發工具,其“插件”主要分為兩類:原生應用擴展(通過Postman應用內置市場安裝)和命令行輔助工具(如Newman)。以下是針對CentOS系統的具體安裝方法:
若需在CentOS上使用Postman的完整功能(如圖形界面、Cookie管理、內置代理),建議安裝原生應用并通過其內置市場擴展功能。
下載并安裝Postman原生應用
.tar.gz
格式)。/usr/local/postman
):sudo mkdir -p /usr/local/postman
sudo tar zxvf Postman-linux-x64-*.tar.gz -C /usr/local/postman
sudo ln -s /usr/local/postman/Postman/Postman /usr/bin/postman
postman
,或在應用菜單中查找“Postman”圖標。通過Postman應用安裝擴展
若需在CentOS上進行API自動化測試(非圖形界面),可通過安裝Newman(Postman的命令行工具)擴展功能。
安裝Node.js和npm
Newman依賴Node.js環境,需先安裝Node.js和npm(Node包管理器):
sudo yum install -y nodejs npm
驗證安裝:
node -v # 查看Node.js版本
npm -v # 查看npm版本
全局安裝Newman
通過npm全局安裝Newman:
sudo npm install -g newman
驗證安裝:
newman -v # 查看Newman版本
使用Newman運行Postman集合
.json
格式)和環境文件(可選)。newman run /path/to/collection.json -e /path/to/environment.json
--reporters html
參數生成HTML報告(需安裝newman-reporter-html
插件):sudo npm install -g newman-reporter-html
newman run /path/to/collection.json --reporters html --reporter-html-export report.html
優勢:Newman支持批量執行、CI/CD集成(如Jenkins、GitLab CI),適合自動化測試場景。
若習慣使用瀏覽器插件,可在CentOS上安裝Chrome瀏覽器后,通過以下方式安裝Postman插件:
開啟開發者模式
打開Chrome,輸入chrome://extensions/
,開啟頂部“開發者模式”。
加載擴展程序
.crx
文件(如通過第三方站點),拖拽至chrome://extensions/
頁面安裝。安裝完成后,可通過Postman的“幫助→檢查更新”功能保持工具最新。