Cypress web自动化24-运行用例生成allure报告

时间:2020-05-28
本文章向大家介绍Cypress web自动化24-运行用例生成allure报告,主要包括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

原文地址:https://www.cnblogs.com/yoyoketang/p/12980242.html