
- Postman 教程
- Postman - 首頁
- Postman - 簡介
- Postman - 環境設定
- Postman - 環境變數
- Postman - 授權
- Postman - 工作流
- Postman - GET 請求
- Postman - POST 請求
- Postman - PUT 請求
- Postman - DELETE 請求
- Postman - 為 CRUD 建立測試
- Postman - 建立集合
- Postman - 引數化請求
- Postman - 集合執行器
- Postman - 斷言
- Postman - 模擬伺服器
- Postman - Cookie
- Postman - 會話
- Postman - Newman 概述
- Postman - 使用 Newman 執行集合
- Postman - OAuth 2.0 授權
- Postman 有用資源
- Postman - 快速指南
- Postman - 有用資源
- Postman - 討論
Postman - 使用 Newman 執行集合
要使用 Newman 執行集合,我們首先需要啟動 Postman 應用程式,然後點選集合名稱旁邊的三個點。有關如何建立集合的詳細資訊在“Postman 建立集合”章節中進行了詳細討論。
執行集合
按照以下步驟使用 Newman 執行集合:
步驟 1 - 點選“匯出”。

步驟 2 - 從“匯出集合”彈出視窗中選擇Collection v2.1(推薦)選項。點選“匯出”。

步驟 3 - 選擇一個位置,然後點選“儲存”。
步驟 4 - 接下來,我們將匯出環境。點選“無環境”下拉選單右側的眼睛圖示。

步驟 5 - 點選“全域性變數”部分中的“編輯”連結。

步驟 6 - 彈出“管理環境”視窗。在“變數”欄位中輸入 URL,在“初始值”欄位中輸入https://tutorialspoint.tw。然後,點選“下載為 JSON”。
最後,選擇一個首選位置,然後點選“儲存”。

步驟 7 - 將環境匯出到與集合位於同一位置。
步驟 8 - 從命令列移動到儲存集合和環境的目錄路徑。然後,執行以下命令:
newman run <"file name">.
檔名應始終用反引號括起來;否則它將被視為目錄名。
Newman 的常用命令列引數
Newman 的常用命令列引數如下所示:
要在環境中執行集合,命令如下:
newman run <name of Collection> -e <name of Environment>
要執行多次迭代的集合,命令如下:
newman run <name of Collection> -n <iteration count>
要使用資料檔案執行集合,命令如下:
newman run <name of Collection> --data <name of file> -n <iteration count> -e <name of Environment>
在請求之間配置延遲時間,命令如下:
newman run <name of Collection> -d <time of delay>
廣告