sudo snap install postman
。sudo dpkg -i postman.deb
,若報依賴錯誤則運行:sudo apt-get install -f
。創建請求
Content-Type
(如application/json
)、認證信息(如Authorization: Bearer <token>
)。raw
格式,輸入JSON數據(如{"key":"value"}
)。發送請求并驗證響應
pm.test("Status code is 200", () => pm.response.to.have.status(200));
pm.test("Response has user ID", () => pm.expect(pm.response.json().id).to.be.a('number'));
。管理測試集合與環境
{{base_url}}
),方便切換測試環境(開發/測試/生產)。高級功能(可選)
newman
命令行工具將測試集成到Jenkins等工具。以上步驟參考自,可根據實際需求選擇安裝方式和測試場景。