前提:為了運行newman,你要確保系統中安裝的Node.js版本是大於v6的。
命令常用選項:
newman [optiions]
- -h:顯示命令行幫助,包括選項列表和簡單的使用案例。
- -v:顯示當前newman的版本。
newman run json文件 [options]
- -e source:用來指定環境變量文件的路徑。
- -g source:用來指定全局變量文件的路徑。
- -r reporter-name:用來指定產生的數據結果的模型,如json,html等。
- --reporter-html-export:指定html報告寫出的路徑。
newman run test.json -e testing.postman_environment.json --reporter-html-export c:\newmanoutput\test_result.json
注:在使用--reporter-html-export進行導出測試結果前,首先需要使用npm install -g newman-reporter-html安裝reporter-html-export,否則測試結果無法自動生成到指定的目錄中。