Esempio n. 1
0
    def run(self):
        """
        run test
        :return:
        """
        global fp
        try:
            fp = open(resultPath, 'wb')
            suite = self.set_case_suite()
            if suite is not None:
                logger.info("*********TEST START***********")
                runner = HTMLTestRunnerCN.HTMLTestRunner(
                    stream=fp,
                    title="Test Report",
                    description="Test Description")
                runner.run(suite)
            else:
                logger.info("Have no case to test")
        except Exception as ex:
            logger.error(str(ex))

        finally:
            MyEmail.get_email()
            logger.info("**********TEST ENDING***********")
            fp.close()
Esempio n. 2
0
 def __init__(self):
     '''初始化'''
     global log, logger, resultPath, on_off
     log = Log.get_log()
     logger = log.get_logger()
     resultPath = log.get_report_path()
     on_off = localReadConfig.get_email("on_off")
     self.caseListFile = os.path.join(readConfig.proDir, "gotham_caselist.txt")
     self.caseFile = os.path.join(readConfig.proDir, "testCase")
     # self.caseFile = None
     self.caseList = []
     self.email = MyEmail.get_email()
     '''定义接口测试报告的title'''
     MyEmail.get_email().subject="gotham接口测试报告" + " " + MyEmail.get_email().date
Esempio n. 3
0
 def run(self):
     """
     run test
     :return:
     """
     try:
         print '获取测试套件...'
         suite = self.set_case_suite()
         if suite is not None:
             logger.info("********测试 开始!********")
             fp = open(resultPath, 'w+')
             runner = HTMLTestRunner.HTMLTestRunner(
                 stream=fp,
                 title='Test Report',
                 description='若要查看详细结果,请下载附件查看!')
             runner.run(suite)
         else:
             logger.info("Have no case to test.")
     except Exception as ex:
         logger.error(str(ex))
     finally:
         logger.info("*********测试 结束!*********")
         fp.close()
     # send test report by email
     if on_off == 'on':
         print '开始发送邮件...'
         send_email = MyEmail.get_email()
         send_email.send_email()
         print '邮件发送完成...'
     elif on_off == 'off':
         logger.info("不需要发动邮件给任何人!")
     else:
         logger.info("是否发送邮件的状态码书写错误!")
Esempio n. 4
0
    def __init__(self, devicePlatN, devicePlatV, deviceName, deviceID,
                 devicePort):
        global log, logger
        global on_off

        self.devicePlatN = devicePlatN
        self.devicePlatV = devicePlatV
        self.deviceName = deviceName
        self.deviceID = deviceID
        self.devicePort = devicePort
        #实例化LOG,
        log = Log.get_log()
        logger = log.get_logger()

        #每个测试终端生成测试报告的文件地址和文件名
        self.resultPath = log.get_report_path(self.deviceID)

        #获取配置文件中是否通过邮件发送报告的开关值on_off
        on_off = localReadConfig.get_email("on_off")
        #实例化发送邮件
        self.email = MyEmail.get_email()

        #读取需要执行的测试用例的文件
        self.caseListFile = os.path.join(readConfig.proDir, "caselist.txt")
        self.caseFile = os.path.join(readConfig.proDir, "testCase")
        self.caseList = []
Esempio n. 5
0
 def __init__(self):
     self.reportpath = log.get_report_path()
     testcasedir = localReadConfig.get_testcasedir("dir")
     self.caseListFile = os.path.join(readConfig.proDir, "caselist.txt")
     self.caseFile = os.path.join(readConfig.proDir,
                                  "testCase") + '\\' + testcasedir
     self.caseList = comm.get_testcase_from_txt()
     self.email = MyEmail.get_email()
Esempio n. 6
0
 def __init__(self):
     global log, logger, resultPath, on_off
     log = Log.get_log()
     logger = log.get_logger()
     resultPath = log.get_report_path()
     on_off = localReadConfig.get_email("on_off")
     self.caseListFile = os.path.join(readConfig.proDir, "caselist.txt")
     self.caseFile = os.path.join(readConfig.proDir, "testCase")
     self.caseList = []
     self.email = MyEmail.get_email()
Esempio n. 7
0
 def __init__(self):
     global log, logger, resultPath, on_off  #初始化变量
     log = MyLog.get_log()                   #启动MyLog的
     # get_log方法开启锁,get_log中又启动Log进行初始化
     logger = log.get_logger()               #获取记录
     resultPath = log.get_report_path()      #生成报告路径
     on_off = localReadConfig.get_email("on_off")  #邮件开关
     self.caseListFile = os.path.join(readConfig.proDir, "caselist.txt")    #设置caselist路径,配置每次执行的case
     self.caseFile = os.path.join(readConfig.proDir, "testCase")            #设置testCase路径
     # self.caseFile = None
     self.caseList = []
     self.email = MyEmail.get_email()                                        #邮件操作
Esempio n. 8
0
    def __init__(self):
        global log, Logger, resultPath, on_off,report_path
        log = MyLog.get_log(logger="AllTest")
        Logger = log.get_logger()
        report_path = log.get_report_path()
        #resultPath = log.get_result_path()
        on_off = localReadConfig.get_email("on_off")
        self.caseListFile = os.path.join(readConfig.proDir, "config_file\\testlist.ini")
        #accept file test
        self.caseFile = os.path.join(readConfig.proDir, "test_case")

        print(self.caseFile)

        # self.caseFile = None
        self.caseList = []
        self.email = MyEmail.get_email()
Esempio n. 9
0
 def __init__(self):
     global log, logger, resultpath, on_off
     log = Log.get_log()
     logger = log.get_logger()
     on_off = localReadConfig.get_email("on_off")
     self.email = MyEmail.get_email()