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")
相关推荐
默_笙6 小时前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
qq_426003966 小时前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫6 小时前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
长沙三为智能科技7 小时前
家政小程序开发从0到上线:五阶段交付流程与验收清单
python
伞伞悦读7 小时前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
只睡四小时8 小时前
Canvas 弹道联机实战:700 行 + 固定时间步长
python·websocket·html5·游戏开发·canvas
奇思妙想聪明勤奋的小羊8 小时前
DeepAgents第5章:子Agent 与上下文隔离—让 Agent学会委派
人工智能·python·学习·语言模型
lpfasd1239 小时前
2026年第38周GitHub趋势周报
python·科技·github
IZero079 小时前
Jev 与 Laya
python·语言模型