unittest08--使用日期时间命名测试报告

2021/11/7 23:42:28

本文主要是介绍unittest08--使用日期时间命名测试报告,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

使用日期时间命名测试报告

导入time模块
    import time
获取日期时间
    now=time.strftime("%Y%m%d %H%M%S")
strftime用于获得指定格式的日期时间字符串
组装报告文件名
    report_filename=now+'_result.html'

调试project_M1

创建report文件夹用于存放测试报告,并修改run.py代码

from project_M1.testcase import login, signup
import unittest,time

from project_M1.runtest import HTMLTestRunner

now = time.strftime('%Y%m%d_%H%M%S')
report_file = '../report/'+now+'.html'
report = open(report_file,'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=report,title='exam接口自动化测试报告',description='测试环境描述')
suite = unittest.defaultTestLoader.discover('../testcase/','*.py')
runner.run(suite)
report.close()


这篇关于unittest08--使用日期时间命名测试报告的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程