【问题标题】:How could I use pytest-html in Pycharm?我如何在 Pycharm 中使用 pytest-html?
【发布时间】:2018-05-03 05:25:27
【问题描述】:

我已经安装了 pytest-html,想用它在 pycharm 中运行 pytest 后生成 html 报告。

像这样:

但它弹出错误:

ERROR: file not found: html=report\result.html

运行后。那么如何修改参数呢?

【问题讨论】:

    标签: pytest pytest-html


    【解决方案1】:

    使用

    --html=Reports/Report.html  --self-contained-html
    

    在pycharm的附加参数部分

    【讨论】:

      【解决方案2】:

      如果您使用终端来运行测试,请尝试使用此方法。

      py.test --html=demoreport.html 
      

      【讨论】:

        【解决方案3】:

        如果你想通过 pycharm 运行,只需右键单击项目,按照以下步骤操作:

        1. 在 Pycharm 中添加新配置:在配置弹出窗口中:单击“+”,Python 测试->pytest,提供“工作目录”和“目标”值以及项目路径。
        2. 然后,在项目的根文件夹中创建一个新文件 pytest.ini 并提供以下值:

           [pytest]
           addopts = --html=reports/Report.html
           python_files = tests/*.py
          

        其中,tests/*.py 是一个包含所有测试的文件夹。

        现在,只需右键单击您的项目并选择 Run 'pytest in ProjectFolderName',您会发现报告是在名为 Report.html 的报告文件夹中创建的

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-04-04
          • 2020-04-25
          • 1970-01-01
          • 1970-01-01
          • 2023-02-11
          • 1970-01-01
          • 1970-01-01
          • 2018-05-24
          相关资源
          最近更新 更多