1.修改了htmltestrunner和单元测试框架的loader两个脚本源码(只能在我上传的资源那里下载)
2.配合以下脚本:
#coding=utf-8 import sys #reload(sys) #sys.setdefaultencoding('utf8') import time import unittest from HTMLTestRunner import HTMLTestRunner import os #一个报告,模块分开 if __name__=="__main__": addr='/test_case/' a=['目录名称1','目录名称2']#新增目录名称需要手动添加 now=time.strftime("%Y-%m-%d %H_%M_%S") fileName="/report/"+now+"result.html" fp=open(fileName,'wb') for i in range(0,len(a)): global discover,runner runner=HTMLTestRunner(stream=fp, title=a[i]+u"测试", description=a[i]+u"测试用例详情" ) #print(i,len(a),addr+a[i]) discover=unittest.defaultTestLoader.discover(addr+a[i],pattern='*only.py',top_level_dir=None) #discover=unittest.TestLoader().discover('D:/python/RMP_AutoTest/bbs/test_case') #discover=unittest.defaultTestLoader.discover('D:\\python\\RMP_AutoTest\\bbs\\TestCase',pattern='*_only.py') runner.run(discover) fp.close()