iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 16
0
DevOps

持續測試三十天系列 第 16

[Day 16] 一份測試報告不夠看,那就看兩份啊!

  • 分享至 

  • twitterImage
  •  

Web 自動化測試完成後,怎麼評估測試結果呢?

這時候測試報告就很重要了,一份完整且直接的測試報告,
有助於衡量測試品質和追蹤問題!

TestCafe 官方提供了多種格式的測試報告,

  1. spec - used by default
  2. list
  3. minimal
  4. xUnit
  5. JSON

一份測試報告不夠看,那就看兩份啊!

Yes

使用官方提供的報告格式

首先我們還是要進到 day14 的 Code

cd day14

使用 spec 格式,設定報告格式的 reporter 可以透過 -r or --reporter 參數。

testcafe chrome TestCafeExamplePage.js -r spec

or

testcafe chrome TestCafeExamplePage.js --reporter spec

https://ithelp.ithome.com.tw/upload/images/20191002/20120775Vd1nOs8PdO.png

使用 list 格式

testcafe chrome TestCafeExamplePage.js -r list

https://ithelp.ithome.com.tw/upload/images/20191002/20120775iIi62kaObI.png

使用 minimal 格式

testcafe chrome TestCafeExamplePage.js -r minimal

https://ithelp.ithome.com.tw/upload/images/20191002/20120775UyCGbs85XE.png

使用 xunit 格式,並輸出成檔案

testcafe chrome TestCafeExamplePage.js -r xunit:report.xml

https://ithelp.ithome.com.tw/upload/images/20191002/20120775G3nmeHUYB2.png

使用 json 格式,並輸出成檔案

testcafe chrome TestCafeExamplePage.js -r json:report.json

https://ithelp.ithome.com.tw/upload/images/20191002/20120775XkpGzE9RcY.png

同時使用 spec 和 json 兩種報告格式,spec 格式顯示在 console 上,並且將 json 格式輸出為檔案。

testcafe chrome TestCafeExamplePage.js -r spec,json:report.json

Installing Plugins

除了官方提供的報告格式之外,在 npm 上 TestCafe reporter on npm 也有許多社群提供的客制化報告格式。
我們可以實際安裝一個客製化格式來看看效果。

安裝客製化格式報告

npm install -g testcafe-reporter-html

or 

npm install --save-dev testcafe-reporter-html

使用客製化格式報告

testcafe chrome TestCafeExamplePage.js -r html:report.html

https://ithelp.ithome.com.tw/upload/images/20191003/20120775pmglos1VIE.png


參考資料

  1. TestCafe reporter on npm
  2. How to create a custom reporter
  3. Scaffold for TestCafe reporter

Some Custom Reporters


上一篇
[Day 15] 世界上沒有一個瀏覽器解決不了的事,如果有那跑兩個!
下一篇
[Day 17] 用圖片和影片讓測試報告更豐富
系列文
持續測試三十天30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言