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")
相关推荐
ZhengEnCi8 小时前
P2M-Matplotlib折线图完全指南-从数据可视化到趋势分析的Python绘图利器
python·matlab·数据可视化
ZhengEnCi10 小时前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽10 小时前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户83580861879111 小时前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L1 天前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅1 天前
海天线算法的前世今生
python·计算机视觉
韩师傅1 天前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L1 天前
LangGraph的MessageState and HumanMessage
python
韩师傅1 天前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L1 天前
python的类&继承
python