def run_case(all_case, reportName="report"):
    '''第二步:执行所有的用例, 并把结果写入HTML测试报告'''
    now = time.strftime("%Y_%m_%d %H_%M_%S")
    report_path = os.path.join(cur_path, reportName)  # 用例文件夹
    #调用BeautifulReport报告模板的方法
    runner = BeautifulReport(all_case)
    runner.report(filename="report%s.html" % now,
                  description='爱学习自动化测试报告',
                  log_path=report_path)
Esempio n. 2
0
 def pool_run_Beautifuhtml(self, suite=None, q=None, process=False):
     """执行用例并输出漂亮报告方法"""
     try:
         name = '/report1' if platform.system(
         ) != 'Windows' else '\\report1'
         if not process:
             suite = self.suite_all
         result = BeautifulReport(suite, verbosity=2)
         results = result.report(filename=name,
                                 description='测试众测报告',
                                 log_path=self.reportFile1,
                                 process=process)
         if process:
             q.put(results)
     except Exception as e:
         log.error(e)
         raise
Esempio n. 3
0
 def process_run_Beautifuhtml(self, suite=None, q=None, process=False):
     """执行用例并输出漂亮报告方法"""
     # global results
     try:
         lock.acquire()
         name = '\\report1'
         if not process:
             suite = self.suite_all
         result = BeautifulReport(suite, verbosity=2)
         results = result.report(filename=name,
                                 description='测试deafult报告',
                                 log_path=self.reportFile1,
                                 process=process)
         if process:
             q.put(results)
             # q.send(results)
             # q.close()
     except Exception as e:
         log.error(e)
         raise
     finally:
         lock.release()
Esempio n. 4
0
        response_fag = ry.read_node_data('CASE_CONF', 'CASE_FIELD', 'RESPONSE', 'IS_WRITE')
        result_col = ry.read_node_data('CASE_CONF', 'CASE_FIELD', 'RESULT', 'INDEX')
        response_col = ry.read_node_data('CASE_CONF', 'CASE_FIELD', 'RESPONSE', 'INDEX')
        # 向Execl写入结果
        copy_data, table_data_w = operation_excel.copy_execl(index)
        for row, value in row_result_dic.items():
            if result_fag:
                operation_excel.write_data(table_data_w, row, result_col, value)
            else:
                break
        for row, value in row_response_dic.items():
            if response_fag:
                operation_excel.write_data(table_data_w, row, response_col, value)
            else:
                break
        operation_excel.save(copy_data)


if __name__ == '__main__':
    time_str = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
    test_suite = unittest.defaultTestLoader.discover(path + r'\\', pattern='test*.py')
    result = BeautifulReport(test_suite)
    result.report(filename='report_' + time_str + '.html', description='测试报告', report_path=path + r'\..\Report')
    print(result.FIELDS['testAll'], result.FIELDS['testFail'], result.FIELDS['testAll'] - result.FIELDS['testFail'],
          result.FIELDS['beginTime'], type(result.FIELDS['beginTime']), result.FIELDS['end_time'])
    # 发送邮件
    send_email = SendEmail(description=u'测试报告', pass_num=result.FIELDS['testAll'] - result.FIELDS['testFail'],
                           fail_num=result.FIELDS['testAll'], start_time=result.FIELDS['beginTime'],
                           end_time=result.FIELDS['end_time'], continue_time=result.FIELDS['totalTime'])
    send_email.send_email()