码迷,mamicode.com
首页 > Web开发 > 详细

HtmlTestRunner二次封装(TestRunner.py)

时间:2016-05-04 22:34:01      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:

将HtmlTestRunner进行二次封装,是报告生成的更方便

import HTMLTestRunner
import unittest
import time, os

class TestRunner(object):

       def __init__(self, cases="./"):
                self.case = cases

       def get_all_cases(self, class_name):
               return unittest.defaultTestLoader.loadTestsFromTestCase(class_name)
def run(self, suite, tittle_text = ‘pywinauto test report‘, description_text=‘‘): for filename in os.listdir(self.cases): if filename == ‘report‘: break else: os.mkdir(self.cases+‘\\report‘) new = time.strftime("%Y-%M-%D-%H_%M_%S") filename = self.cases+‘\\report\\‘+new+‘result.html‘ fp = file(filename, ‘wb‘) runner = HTMLTestRunner.HTMLTestRunner(stream=fp, tittle=tittle_name, description=description_text) runner.run(suilt) fp.close() if __name__ == ‘__main__‘: test = TestRunner() test.run()

 

HtmlTestRunner二次封装(TestRunner.py)

标签:

原文地址:http://www.cnblogs.com/ybcao/p/5459940.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!