pytest-testreport测试报告

背景

自动化测试项目中需定长时间执行测试用例,所有测试用例执行完未达到设置的定长时间继续重复执行所选测用例,最开始使用Allure生成测试报告,但会出现问题就是每次重新执行测试用例的报告会覆盖之前的,后面选择了pytest-testreport的原因是他有历史构建结果,虽然没有Allure之酷炫,只为历史结果记录才做此取舍,或者有哪位大咖能在Allure基础上解决这个问题,欢迎评论讨论。

简介

pytest-testreport: pytest生成html测试报告的插件,报告中会自动收集用例执行的详细日志信息,以及相关错误和输出信息

安装

pip install pytest-testreport

参数

--report :指定报告文件名

--title :指定报告标题

--tester :指定报告中的测试者

--desc :指定报告中的项目描述

--template :指定报告模板样式(1 or 2)

def pytest_addoption(parser):
    group = parser.getgroup("testreport")
    group.addoption(
        "--report",
        action="store",
        metavar="path",
        default=None,
        help="create html report file at given path.",
    )
    group.addoption(
        "--title",
        action="store",
        metavar="path",
        default=None,
        help="pytest-testreport Generate a title of the repor",
    )
    group.addoption(
        "--tester",
        action="store",
        metavar="path",
        default=None,
        help="pytest-testreport Generate a tester of the report",
    )
    group.addoption(
        "--desc",
        action="store",
        metavar="path",
        default=None,
        help="pytest-testreport Generate a description of the report",
    )
    group.addoption(
        "--template",
        action="store",
        metavar="path",
        default=None,
        help="pytest-testreport Generate a template of the report",
    )

报告模板二

[pytest]
addopts = -v --reruns 1 --reruns-delay 1 --report=_testreport.html --title="MTBF Testing Report" --tester=xiaowei --desc="MTBFTesting" --template=2

注意

可能会与pytest-html存在冲突,若冲突需要卸载pytest-html

posted @ 2024-07-30 20:23  小小滴人a  阅读(0)  评论(0编辑  收藏  举报