运行文件,包括生成测试报告
#coding=utf-8
import unittest, time, os, sysfrom HTMLTestRunner import HTMLTestRunner
reload(sys)
# sys.setdefaultencode('utf-8')
sys.setdefaultencoding('utf8')
class RunTestCase(object):
def __init__(self):
pass
def Test_Report(self):
'''测试报告
包括__生成测试报告
'''
New_time = time.strftime('%Y-%m-%d %H_%M_%S')
File_path = os.path.join('./Report/' + New_time + ' report.html')
with open(File_path, 'wb') as Fp:
runner = HTMLTestRunner(stream=Fp,
title=u'天梯项目--------自动化成测试报告',
description=u'浏览器:Firefox\n\
系统:win7\n\
用例执行情况:')
runner.run(self._RunCase())
def _RunCase(self):
'''运行各个文件夹里面的测试用例
TestCase--->Proces_Manage
--->Test_Manage
'''
discover = unittest.defaultTestLoader.discover(start_dir='./TestCase',
pattern='Case_*.py'
)
return discover
if __name__ == '__main__':
Run = RunTestCase()
Run.Test_Report()
测试报告样式: