from lib.path import APPCASE, LOGPATH,APPREPORT
# from lib.HTMLTestAppRunner import HTMLTestRunner
import unittest
from lib.appController import Controller
from BeautifulReport import BeautifulReport
class Main(object):
def __init__(self):
self.controller = Controller()
self.deviceName = self.controller.deviceName
def run(self):
self.controller.start_server()
if self.controller.test_server():
self.controller.start_driver()
suite = unittest.TestSuite()
cases = unittest.defaultTestLoader.discover(APPCASE)
for case in cases:
suite.addTest(case)
run = BeautifulReport(suite)
run.report(filename = ‘{}.html‘.format(self.deviceName),description = ‘用例执行情况‘,
log_path = APPREPORT)
# f = open(APPREPORT.format(‘{}.html‘.format(self.deviceName)), ‘wb‘)
# runner = HTMLTestRunner(f, verbosity=1, title=u‘测试报告‘, description=u‘用例执行情况:‘)
# runner.run(suite)
# f.flush()
# f.close()
if __name__ == ‘__main__‘:
m = Main()
m.run()
AppUi自动化框架main.py代码