python+selenium2轻量级框架设计-10执行脚本

import BeautifulReport,unittest,os,time
from framework.email import Email
#测试报告路径

report_path = os.path.dirname(os.getcwd())+'/framework_demo/'
now_time = time.strftime('%Y-%m-%d_%H.%M')
report_name = now_time + '测试报告.html'
#跑用例
test_dir = './framework_demo/testsuits'
suite = unittest.defaultTestLoader.discover(test_dir)
if __name__=='__main__':
    #生成测试报告
    result = BeautifulReport.BeautifulReport(suite)
    result.report(filename=report_name,
                  description='百度测试报告',
                  log_path=report_path)
    #取最新报告
    new_email = Email(email='.')
    new_report = new_email.new_file(report_path)
    print(new_report)
    #发送邮件
    new_email.send_email(new_report)

testrunner中包含了运行测试用例脚本,生成测试报告,发送测试邮件等功能。用到的方法在前面都有讲过或者代码注释都有。

这里用的是BeautifulReport,因为好看一点

猜你喜欢

转载自blog.csdn.net/u013434475/article/details/83012896
今日推荐