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")
相关推荐
金銀銅鐵10 小时前
[Python] 从《千字文》中随机挑选汉字
后端·python
cup1115 小时前
[技术复盘] Windows Python 打包实战:Nuitka 环境踩坑总结与 CI 自动化构建全指南
python·ai·环境变量·ci·nuitka·skill
aqi0017 小时前
15天学会AI应用开发(七)有了大模型为什么还要引入RAG
人工智能·python·大模型·ai编程·ai应用
金銀銅鐵19 小时前
用 Python 实现 Take-Away 游戏
python·游戏
copyer_xyf20 小时前
Agent 流程编排
后端·python·agent
copyer_xyf20 小时前
Agent RAG
后端·python·agent
copyer_xyf20 小时前
【RAG】向量数据库:milvus
后端·python·agent
copyer_xyf21 小时前
Agent 记忆管理
后端·python·agent
星云穿梭1 天前
用Python写一个带图形界面的学生管理系统——完整教程
python