0

有没有办法在 pytest 生成的 html 报告中包含取消选择的测试,类似于跳过的测试?

  • 生成的html文件:file: ////////reports/report.html - ================ 13个通过,41个跳过,6个在35.54s内取消选择== ================

我找到了一个解决方案,通过将其添加到conftest.py将它们打印在终端中

def pytest_deselected(items):
    if not items:
        return
    config = items[0].session.config
    reporter = config.pluginmanager.getplugin("terminalreporter")
    reporter.ensure_newline()
    for item in items:
        reporter.line(f"deselected: {item.nodeid}", yellow=True, bold=True)

但无法弄清楚如何在报告中列出这些测试 在此处输入图像描述

4

1 回答 1

0

我最终将它们标记为已跳过而不是取消选择它们,这样它们就可以轻松地列在报告中。

于 2020-08-06T15:47:16.720 回答