在做介面測試時經常會用到postman,但是一直沒有總結過,太過零散,這次找了一些好的資料,結合自己平時所用到的功能,總結一波
開啟postman,主介面如下

左側選單
1.History標籤
裡面儲存的是使用postman傳送過的請求,postman會把每一個請求自動儲存到history標籤,可以起到一個查詢的作用

2.Collections
集合,建立集合有助於我們對不同介面進行分類管理:比如不同程式的介面、同一個程式不同功能類別的介面,通過集合來區分它們,看起來簡潔明瞭,方便後續的維護;
同時我們在建立集合後,也可以一次性執行集合中的所有請求,不必再一個個單獨執行

(1)建立一個頂級集合:點選Collections下方的“資料夾”圖示即可

(2)在一個集合中建立子集合:選中一個集合,然後按下滑鼠右鍵,選擇"Add folder"
ps.右鍵一個集合後可以看到許多操作按鈕, 如重新命名、匯出、刪除等

頂部選單

New按鈕:
提供建立請求、集合、環境、文件、mock伺服器和監控器的入口;

Import按鈕:
提供集合匯入、環境匯入等的入口;

Runner按鈕:
開啟collection runner視窗,能夠批量執行一個collections中的請求,同時生成報告;

Open New按鈕:
用於開啟一個新的tab、一個新的Postman視窗、一個新的collection runner;

設定

Trim keys and values in request body:如果使用form-data或者url-encoded的方式向伺服器傳送資料;將該選項設定為ON,則會引起引數左右兩側的空格被刪除;
SSL certificate verification:防止應用程式在發出請求時檢查SSL證書的有效性;
Language detection:將此設定為JSON將強制執行JSON呈現,而不管響應Content-Type標頭;
Request timeout in ms(0 for infinity):在顯示伺服器沒有響應之前,設定應用等待響應的時間(單位時ms)。 0表示無窮大-Postman將永遠等待響應;
Send no-cache header:傳送一個no-cache標頭可以確保請求從伺服器獲得最新的響應,而不是快取資料;
Send Postman Token header:這主要用於繞過Chrome中的錯誤。如果XmlHttpRequest處於掛起狀態,並且使用相同的引數傳送另一個請求,則Chrome會為它們返回相同的響應。傳送隨機令牌可避免此問題。這也可以幫助我們在伺服器端區分請求;
Retain headers when clicking on links:如果點選響應報文中的連結,Postman會使用該URL建立一個新的GET請求。如果希望該請求繼續使用前一次請求中的頭部資訊,該選項就應該設定為ON;這個選項對於訪問受保護的資源非常有用;
Automatically follow redirects:阻止返回300系列響應的請求被自動重定向;
Send anonymous usage data to Postman:說白了就是是否同意Postman採集我們的使用資訊。
工作臺

上面是傳送請求request模組,下面是響應response模組
1.請求
選擇請求方法,填寫請求url、引數,點選【send】即可傳送一次請求

2.響應
傳送請求後,接收到的響應內容會在response模組展示

2018-12-19