allure 与 pytest 集成

在上一篇文章中,我们知道了如何安装allure,接下来我们将学习如何将 allure 和 pytest 集成起来。

实现 allure 与 pytest 的集成后,能够在 pytest 运行完成后,生成 allure 文件,方便我们查看效果更好的测试报告。

 

1、安装插件,在cmd.exe命令行工具中运行以下命令:

  pip install allure--pytest

 

2、在 pytest 命令里,添加 allure 参数:--alluredir=Outputs/allure_reports,如下所示

(Outputs 目录与 TestCases 为同级目录,Outputs/allure_reports 为相对路径)

 

 

3、待 pytest 收集到的所有用例运行完成后,就会在 allure_reports 文件夹下生成 allure 文件

 

 

 4、在 parcharm 的 Terminal 执行命令:allure serve Outputs/allure_reports,即可生成 allure 格式的 HTML 报告

 

 5、生成的测试报告如下,是不是很 beautiful 。

 

posted @ 2020-04-04 12:06  安金小玉  Views(732)  Comments(0Edit  收藏  举报