原文链接:http://www.cnblogs.com/Detector/p/7511294.html
#coding:utf-8 from HTMLTestRunner import HTMLTestRunner import time import os import unittest now = time.strftime(u"%Y.%m.%d@%H%M%S") filename = os.path.abspath('Report-') + now + '.html' test_dir = os.getcwd() bingo = unittest.defaultTestLoader.discover(test_dir, pattern='*t*') #获取当前路径所有含有字母't'的文件 fp = open(filename, 'wb') # runner = unittest.TextTestRunner() runner = HTMLTestRunner(stream=fp, title=u'测试报告', description=u"操作系统 :windows7,Chrome") runner.run(bingo) fp.close()
本文介绍了一个使用Python结合HTMLTestRunner自动生成HTML格式测试报告的方法。该脚本通过遍历当前目录下所有包含字母't'的文件,执行这些测试用例,并将结果汇总成一个详细且易于阅读的HTML报告。
3万+

被折叠的 条评论
为什么被折叠?



