我正在使用 pytest-html 插件。在命令行中传递参数时会生成 html 报告。需要自动创建 html 报告,并且 html 报告链接应该显示在终端中。
3 回答
3
您可以将 cmdline 参数放在pytest.ini
根目录下的文件中
$ cat pytest.ini
[pytest]
addopts = --html=report.html --self-contained-html
于 2019-06-06T17:32:39.913 回答
0
替代选择,就像尼扎尔的回答
def pytest_cmdline_preparse(config, args):
config.option.htmlpath = "my-report.html"
config.option.self_contained_html = True
于 2021-09-22T12:27:50.797 回答
0
您可以通过在文件中编写pytest_cmdline_preparse()
挂钩来执行此操作conftest.py
def pytest_cmdline_preparse(config, args):
html_file = func_to_generate_html_filename()
print('HTML report file:', html_file)
args.extend(['--html', html_file, '--self-contained-html'])
于 2019-06-07T04:53:12.810 回答