pytest中生成allure报告时,测试报告中统计的用例数不正确

【问题描述】:pytest中生成allure报告时,测试报告中统计的用例数不正确,用例数总是比实际用例数多

【问题定位】:因为生成index.html的allure报告,是根据临时的json文件生成的。每次运行时,没有删除旧的json文件,所以导致报告中的用例数是旧的json文件+新的json文件产生的总数,所以会不正确。

【解决办法 】:生成allure报告语句中,要注意先删除旧的json文件,由新的json文件产生新的index.html报告。具体如下:

pytest.main("test_vip.py", "-s", "--alluredir", ".../result/tmp", "**--clean-alluredir**") # 产生临时json文件之前,先清空**--clean-alluredir**

python 复制代码
if __name__ == '__main__':
    #指定生成临时json文件的路径为/result/tmp,注:这里一定要加"--clean-alluredir",每次运行都清空tmp文件,不然统计的用例数会不正确
    pytest.main(["test_vip.py", "-s", "--alluredir", "../result/tmp", "--clean-alluredir"])  # -s 打印输出,指明报告路径
    #通过临时的json文件产生allure报告,../result/tmp为json文件的位置,../result/report为allure报告文件的位置
    os.system("allure generate ../result/tmp -o ../result/report --clean")
相关推荐
timeDifference₇8 小时前
Python Vibe Coding实操实验报告
开发语言·jvm·python
geovindu9 小时前
python:DecisionTree
开发语言·后端·python·算法
怒放的生命199110 小时前
代码知识库 RAG 问答系统 —— 从 0 到 1 实现教程
python·状态模式·fastapi·全栈开发·ai agent应用开发
geovindu10 小时前
python: Decision Tree Regressor
开发语言·后端·python·算法·决策树
fengkai454511 小时前
Python运维
运维·python·监控·psutil·ipy
Fancy.76111 小时前
:Python条件与循环语句学习总结
python
Wellijohn13 小时前
Python 容器选型实测:list.insert(0) 慢 925 倍,in 慢 6000 倍
python
新*13 小时前
标题全变成一级?靠编号规律找回章节边界
python·正则表达式·pdf解析·文本处理
高洁0116 小时前
多源数据融合:把零散信号拼成一致图景
人工智能·python·机器学习·transformer·迁移学习
郝学胜-神的一滴16 小时前
Effective Python 条款41:试Mix‑In组合式开发
开发语言·pytorch·python·pycharm·numpy