Cypress web自動化24-運行用例生成allure報告


前言

在cypress run的執行過程中,每一個測試用例文件都是完全單獨運行的。執行完用例后可以生產對應的報告文件,再結合 allure 可以生成 allure 的報告。

junit-allure報告

在 cypress.json 中加入如下配置

// 作者:上海-悠悠 交流QQ群:939110556
// 原文blog: https://www.cnblogs.com/yoyoketang
{

  "reporter": "junit",
  "reporterOptions": {
    "mochaFile": "results/test_report_[hash].xml", 
    "toConsole": true
  }
}

從Cypress 3+開始,在cypress run的執行過程中,每一個測試用例文件都是完全單獨運行的,這意味着后面的測試結果會覆蓋之前的測試結果呢。
為了針對每個測試文件生成單獨的測試報告,請在mochaFile文件中使用[hash]:

"mochaFile": "results/test_report_[hash].xml"

也可以通過命令行傳對應的參數

cypress run --reporter junit --reporter-options "mochaFile=results/test_report_[hash].xml,toConsole=true"

運行用例

通過cypress run 運行測試用例

cypress run --browser chrome

用例運行后會在report目錄下生成xml報告

allure命令行工具

allure是一個命令行工具,需要去github上下載最新版https://github.com/allure-framework/allure2/releases

下載完成之后,解壓到本地電腦

把bin目錄添加到環境變量Path下

allure報告

cd到cypress 項目根目錄執行

allure serve results

生成 allure 測試報告


作者:上海-悠悠 交流QQ群:939110556
原文blog: https://www.cnblogs.com/yoyoketang


免責聲明!

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



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