1. 程式人生 > >使用newman執行介面測試用例

使用newman執行介面測試用例

 

一、安裝Newman npm install -g newman     二、執行case newman run case生成的json檔案   三、引數 npm install -g newman
  • -e <source>, --environment <source>
設定環境變數
  • -g <source>, --globals <source>
設定全域性變數   -r cli   -r json 生成cli或json格式的報告   需要執行命令 npm install -g newman-reporter-html
來全域性安裝支援Newman生成html報告的元件 然後,再次執行命令 newman run Postman_API_test.postman_collection.json -d data.json -r html 一般常用以下命令 newman run 用例集json -e 環境變數json -g 全域性變數json   四、示例 1、設定environment環境 -e 執行以下命令 newman run test.postman_collection.json -e test.postman_environment.json >d://error.log
執行結果   由於介面依賴登入,未設定登入cookie導致請求失敗,故需要將cookie設定為全域性變數   2、設定全域性變數 -g 執行以下命令 newman run test.postman_collection.json -e test.postman_environment.json -g C:\Users\test.postman_global.json >d://error1.log