自动化工具 [已解决] 如何给 allure report test body 处增加日期时间戳?

strayeagle · 2020年03月04日 · 最后由 strayeagle 回复于 2020年03月07日 · 3331 次阅读

pytest+allure,目前生成的 allure report 有一点不满意,如下图所示:

这里展开的 log 是没有日期时间戳的,如果某个时刻用例出错,可以根据 log 中显示的时间戳,直接查找对应时间点的产品 log,对定位问题提供很大的便捷。

目前苦于不知道如何增加时间戳,预期 allure report 中显示的日志效果如下:

请教下各位如何解决的,感谢~

共收到 3 条回复 时间 点赞


你自己写个日志输出模块加上时间戳,输出内容到控制台,报告会自动给你收集起来

快达年 回复

没有单独写一个 log 模块,使用的 pytest.ini,在里面定义了 log 格式:

[pytest]
log_cli = true
log_level = NOTSET
log_file = ../report/xxx.log
log_file_format = [%(filename)s:%(lineno)-4s] [%(levelname)5s] %(asctime)s %(message)s
log_file_date_format=%Y-%m-%d %H:%M:%S
log_cli_level = INFO
log_cli_format = %(asctime)s [%(filename)s:%(lineno)-4s] [%(levelname)5s] %(message)s
log_cli_date_format=%Y-%m-%d %H:%M:%S

没有达到预期的效果。。。。

问题已经,在 pytest.ini 文件中,增加了 log_format && log_data_format
log_format = %(asctime) s [%(filename) s:%(lineno)-4s] [%(levelname) 5s] %(message) s
log_date_format=%Y-%m-%d %H:%M:%S

strayeagle 关闭了讨论 03月07日 11:03
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册