UI自动化web端框架run.py代码

import unittest
import time
from lib.core.tools import get_new_report, remove_report
from lib.core.path import CASE_PATH, REPORT_PATH, EMAIL_INFO
from lib.core.sendmail_new import SendMail
from BeautifulReport import BeautifulReport
from lib.core.HTMLTestRunner import HTMLTestRunner

user = EMAIL_INFO.get('user') # 从配置文件中获取邮件用户名
password = EMAIL_INFO.get('password') # 从配置文件中获取邮箱授权码
host = EMAIL_INFO.get('host') # 从配置文件中获取邮件服务器
to = EMAIL_INFO.get('to') # 从配置文件中获取邮件接收者
cc = EMAIL_INFO.get('cc') # 从配置文件中获取抄送邮箱
subject = EMAIL_INFO.get('subject') # 从配置文件中获取邮件标题
contents = EMAIL_INFO.get('contents') # 从配置文件中获取邮件内容
attachments = EMAIL_INFO.get('attachments') # 从配置文件中获取邮件


def run():
# 生成了测试集
suite = unittest.TestSuite()
# 根据测试case的路径自动加载测试用例
cases = unittest.defaultTestLoader.discover(CASE_PATH)
for case in cases:
suite.addTest(case)
# f = open(REPORTPATH, "wb")
run = BeautifulReport(suite)
run.report(filename='%s_report.html' % time.strftime('%Y%m%d%H%M%S'), description='UI自动化测试报告',
log_path=REPORT_PATH)
# htmlrunner运行
# runner = HTMLTestRunner(stream=f, title=u'测试报告', description=u'用例执行情况:')
# runner.run(suite)
# f.flush()
# f.close()


if __name__ == '__main__':
run()
filename = get_new_report()
send = SendMail(user, password, host, to, cc, subject, contents, filename)
send.send_mail()
remove_report()

转载于:https://www.cnblogs.com/laosun0204/p/9267458.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值