转载自博客园作者Findyou,https://www.cnblogs.com/findyou/p/6925733.html
[项目地址] https://github.com/findyou/HTMLTestRunnerCN/tree/dev
适用于python3:
下载地址:
英文:https://pan.baidu.com/s/1Xb8VG6UFxR_R6aSqZumwWw
中文:https://pan.baidu.com/s/1Hmi-brNTTgtbDqzb1IVuHQ
使用方法:
HTMLTestRunnerCN.py和HTMLTestRunnerEN.py下载到...\python\Lib目录下,在使用时导入该模块即可。
# coding:utf-8 import unittest, time
from HTMLTestRunnerCN import HTMLTestRunner if __name__ == ‘__main__‘: suite = unittest.TestSuite() suite.addTest(TestCalculator(‘test_add‘)) suite.addTest(TestCalculator(‘test_sub‘)) now_time = time.strftime("%Y%m%d_%H-%M-%S") file_path = open(‘./‘+now_time+‘_TestResult.html‘, ‘wb‘) runner = HTMLTestRunner( stream=file_path, # 文件 title=‘计算器测试报告‘, # 标题 description=‘测试用例执行情况‘, # 副标题 tester=u"fancy" # 测试人员名字,不传默认为QA ) runner.run(suite) file_path.close()
英文报告:
# coding:utf-8 import unittest, time from HTMLTestRunnerEN import HTMLTestRunner if __name__ == ‘__main__‘: suite = unittest.TestSuite() suite.addTest(TestCalculator(‘test_add‘)) suite.addTest(TestCalculator(‘test_sub‘)) now_time = time.strftime("%Y%m%d_%H-%M-%S") file_path = open(‘./‘+now_time+‘_TestResult.html‘, ‘wb‘) runner = HTMLTestRunner( stream=file_path, # 文件 title=‘计算器测试报告‘, # 标题 description=‘测试用例执行情况‘, # 副标题 tester=u"fancy" # 测试人员名字,不传默认为QA ) runner.run(suite) file_path.close()
测试报告结果如图
中文:
英文: