หลายๆคนที่ใช้ Postman กันอาจจะไม่รู้ว่า Postman สามารถที่จะ run ผ่าน command line ได้ โดยจะใช้ Newman เข้ามาช่วย (อ่านต่อเพิ่มเติมว่า Newman คืออะไรได้ใน Reference)
ในตัวอย่างนี้กาดใช้ External report ที่ชื่อว่า htmlextra นะ นอกเหนือจากนั้นลองดูในเอกสารของ newman นะ
วัตถุดิบที่เราจะให้ออก Report
ได้แก่
- file script test (shopping-cart-success)
- data file (test-data.json)
- config file (local.json)
ก่อนที่จะ Run script test ชุดนี้จะต้องติดตั้ง Extention เพิ่มเติมก่อน
npm install -g newman-reporter-htmlextra
เมื่อติดตั้งเสร็จแล้วก็สามารถที่จะออก Report ได้เลยด้วยคำสั่ง
-r htmlextra --reporter-htmlextra-export <path>
Example
-r htmlextra --reporter-htmlextra-export ./results/report.html
หลังจากนั้นให้ Run script test ได้เลย
Example
newman run shopping-cart-success -d data/test-data.json -e environment/local.json -r htmlextra --reporter-htmlextra-export ./results/report.html
หลังจาก Run เสร็จจะมี Folder ที่ชื่อ results และไฟล์ report.html ขึ้นมา
ผลลัพธ์ที่ได้
Reference : https://www.npmjs.com/package/newman-reporter-htmlextra