pytest-Allure报告

参考:https://www.cnblogs.com/yoyoketang/p/12004145.html

安装

  1. pip install pytest
  2. pip install allure-pytest
  3. 安装allure
    github下载https://github.com/allure-framework/allure2/releases
    下载后解压到本地\Python\Python38\Lib\site-packages
    配置环境变量,添加指向到bin的文件。 Python\Python38\Lib\site-packages\allure-2.13.5\bin
  4. 验证
    安装后,cmd输入allure,如果出现报错module 'allure' has no attribute 'severity_level',
    说明allure-pytest与 pytest-allure-adaptor不能共存,写在 pytest-allure-adaptor即可,卸载pip uninstall pytest-allure-adaptor

使用

  1. 执行
    在可以运行pytest的路径下
    cmd:pytest --alluredir ./report
    pycharm:
    args = ['-m', 'loginTest', '--alluredir', "./allureReport"] # 生成allure报告
    pytest.main(args)
  2. 整理
    cmd:allure generate report/ -o report/html --clean report
    pycharm:切换到terinal下,输入allure generate report/ -o report/html --clean report
  3. 查看
    会在report下生成一个html文件夹,打开其中的index.html

配置

可以有很多高级的使用,比如与Jenkins连用。

posted @ 2020-09-17 17:50  Alice1005  阅读(128)  评论(0编辑  收藏  举报