分享

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

 上海悠悠 2021-05-27

前言

在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/testreport[hash].xml”

也可以通过命令行传对应的参数

cypress run —reporter junit —reporter-options “mochaFile=results/testreport[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 测试报告

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多