1.测试工程目录
from tools.HTMLTestReportCN import HTMLTestRunner import time,os,unittest class TestRunner(object): def __init__(self,cases=‘./‘,title=u‘自动化测试报告‘,description=u‘环境:windows 10‘): self.cases = cases self.title = title self.des = description def run(self): # for filename in os.listdir(self.cases): # if filename == ‘report‘: # break # else: # os.mkdir(self.cases+‘/report‘) now = time.strftime(‘%Y%m%d%H%M%S‘) with open("./report/Report"+".html", ‘wb‘) as fp: suites = unittest.defaultTestLoader.discover(‘./case‘,pattern=‘test*.py‘) # 测试套件- 定义测试代码目录和测试用例前缀 HTMLTestRunner(stream=fp,title=self.title,description=self.des).run(suites) fp.close() if __name__ == ‘__main__‘: test = TestRunner() test.run()
原文:https://www.cnblogs.com/wsy0202/p/12845319.html