如何在 Cypress 中建立 Junit 報告?
我們可以在 Cypress 中建立一個 Junit 報告。要安裝用於 JUnit 報告的程式包,執行命令 −
npm install cypress-junit-reporter --save-dev
示例
在 cypress.json 中實現
{ "reporter": "junit", "reporterOptions": { "mochaFile": "cypress/results/results.xml", "toConsole": true } }
如果我們在一次執行中執行多個測試,並且希望為每個 spec 檔案生成一個唯一的報告,我們必須在 cypress.json 中的 mochaFile 引數中新增 [hash]。
示例
在 cypress.json 中實現以避免報告覆蓋
{ "reporter": "junit", "reporterOptions": { "mochaFile": "cypress/results/results-[hash].xml", "toConsole": true } }
要為 Cypress 專案的 integration 資料夾中的所有規範生成報告,請執行命令 −
npx cypress run --reporter junit
執行完成後,結果資料夾將在 Cypress 專案中生成包含 xml 格式報告。
廣告