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()
上一篇:[转帖]xserver相关知识汇总


下一篇:亚马逊点Report abuse删差评的详细方法