自动化测试-19-测试报告分离

测试报告分离
 
1. 新建测试报告目录;
2. 将测试结果保存到测试报告目录;
 
 

run.py编写:

import os
import time


current_path = os.path.dirname(os.path.realpath(__file__))
print(current_path)
report_path = os.path.join(current_path,'report')
print(report_path)
case_path = os.path.join(current_path,'test','case')
print(case_path)
report_name = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
print(report_name)


testsuite = unittest.TestLoader().discover(case_path)
filename = "{}\{}.html".format(report_path,report_name)
f = open(filename, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=f, title='redmine report',description='this is a report')
runner.run(testsuite)
f.close()
原文地址:https://www.cnblogs.com/jenny-jenny/p/14713497.html