Beispiel #1
0
                                 'ushayden_interface_autotest_report')
        html_report.set_time_took(str(end_time - start_time))  # 计算测试消耗时间

        # 读取测试报告路径及文件名
        config = configparser.ConfigParser()
        config.read('./config/report.conf', encoding='utf-8')
        dir_of_report = config['REPORT']['dir_of_report']
        report_name = config['REPORT']['report_name']

        # 设置报告生成路
        html_report.mkdir_of_report(dir_of_report)

        # 生成测试报告
        html_report.generate_html(report_name)

        logger.info('生成测试报告成功')

        mymail = MyMail('./config/mail.conf')
        mymail.connect()
        mymail.login()
        mail_content = 'Hi,附件为接口测试报告,烦请查阅'
        mail_tiltle = '【测试报告】接口测试报告' + str(executed_history_id)
        logger.info(html_report.get_filename())
        attachments = set([html_report.get_filename()])

        logger.info('正在发送测试报告邮件...')
        mymail.send_mail(mail_tiltle, mail_content, attachments)
        mymail.quit()

        logger.info('发送邮件成功')
Beispiel #2
0
test_detail(worksheet2)
init(worksheet)
workbook.close()


msg = """
<table width = "800" border="0" cellspacing="0" cellpadding="4">
    <tr>
        <td  height="20" style="font-size:24px">接口自动化测试报告</td>
    </tr>
"""



try:
    logger.info ('生成测试报告成功')
    mymail = MyMail(GetTestConfig('mail.conf'))
    mymail.connect()
    mymail.login()
    mail_content = msg.format(len(TestReport), hpassnum, len(TestReport)-hpassnum, round(hpassnum/len(TestReport),2)*100, now)
    mail_title = '【接口自动化测试报告】'
    attachments = set([ReportPath])

    logger.info("发送测试报告....")
    mymail.send_mail(mail_title, mail_content, attachments)
except Exception as e:
    logger.error("邮件发送失败"+ str(e))
    mymail.quit()
else:
    mymail.quit()