postman+newman+jenkins接口自動化


postman用來做接口測試非常方便,接口較多時,則可以實現接口自動化

目錄

1、環境准備

2、本機調試腳本

3、集成jenkins

 

 

1、環境准備

1.1安裝nodejs6.0+

安裝nodejs6.0+(github上面寫的版本要求),用於安裝newman4.0+,到nodejs官網下載即可https://nodejs.org/en/download/releases/

 

1.2安裝newman

npm install -g newman

1.3安裝newman-reporter-html

npm install -g newman-reporter-html

  

2、本機調試腳本

2.1了解命令行執行腳本

可以查看github上面的命令說明https://github.com/postmanlabs/newman#configuring-reporters、https://github.com/postmanlabs/newman-reporter-html#readme

run XX.json                                                                 #執行腳本

---reporters html --reporter-html-export /路徑             #導出執行結果到此路徑,若指定輸出報告,則只會在dos窗口輸出執行結果

 -e XX.json                                                                  #帶上環境變量

2.2從postman下載腳本到本機

下載腳本:

下載環境變量:

2.3本機調試出報告

newman run D:\test.postman_collection.json --reporters html --reporter-html-export  D:\html01.html

在D盤下生成報告

 

3、集成jenkins

 和其他項目配置jenkins一樣,新建一個構建,然后在構建的地方,配置一下,windows的批處理命令

點擊立即構建,查看控制台輸出

 

 在D盤下同樣會生成報告

 

另:

1、還可以配置發送郵件等,本篇暫未介紹


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM