【问题标题】:How to enable PyTest HTML reporting from within the code and not from the System Terminal?如何从代码中而不是从系统终端启用 PyTest HTML 报告?
【发布时间】:2020-03-06 19:33:55
【问题描述】:

我知道的一种生成 HTML 报告的方法是从系统终端运行,但我希望我的代码能够动态处理它,这样当我从终端运行代码时,我不必传递 --html=report.html 参数。

【问题讨论】:

  • 你所说的动态是什么意思?您可以将选项放入pytest.ini,或以编程方式设置。
  • 我的意思是每当我运行我的测试时,它应该在这个目录“./reports/automation.html”的最后生成一个 HTML 报告

标签: pytest pytest-html


【解决方案1】:

在运行 pytest 的目录中创建一个pytest.ini。然后,您可以在运行 pytest 时使用 addopts 变量添加默认参数。看起来像这样的东西:

pytest.ini

[pytest]
addopts = --html=reports/automation.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-03
    • 1970-01-01
    • 2021-05-27
    • 1970-01-01
    • 2010-11-24
    • 1970-01-01
    • 2015-11-09
    • 1970-01-01
    相关资源
    最近更新 更多