在上一篇文章中,我们知道了如何安装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 为相对路径)

allure 与 pytest 集成

 

 

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

 allure 与 pytest 集成

 

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

allure 与 pytest 集成

 

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

allure 与 pytest 集成

 

相关文章:

  • 2022-12-23
  • 2021-12-23
  • 2021-12-27
  • 2021-09-25
  • 2021-12-28
  • 2021-10-09
  • 2021-12-10
猜你喜欢
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-19
  • 2021-06-17
  • 2022-01-26
  • 2022-12-23
相关资源
相似解决方案