#获取当前时间 now = time.strftime("%Y-%m-%d_%H_%M_%S") #定义报告存放地点 xmlpath = os.path.split(os.path.realpath(__file__))[0] #获取当前路径 xmlpath2 = xmlpath.split('src')[0] filename = xmlpath2+'log\\'+now+'result.html' source1 = xmlpath2+r"log" target_dir1 = "D:\\jenkins\\workspace\\POS_001" #获取ini路径 inipath = xmlpath2+'testdata\\config.ini' #ini文件载入 config = ConfigParser.ConfigParser() config.readfp(open(inipath)) mail_from = config.get('mail','from') mail_to = config.get('mail', 'to') fp = file(filename, 'wb') runner =HTMLTestRunner.HTMLTestRunner( stream=fp, title=u'个险保全系统测试报告', description=u'用例执行情况:') if __name__ == '__main__': #检查数据文件是否需要更新 db2file.updataFile() alltestnames = creatsuite() runner.run(alltestnames) fp.close() reportname = Autotest.newfile(xmlpath2+'log\\') Autotest.sendMail(mail_from,mail_to, '核心系统自动化运行结果', reportname) Autotest.copynewfiles(source1,target_dir1)
__author__ = "fengpinghu" # coding=utf-8 import os from public import Autotest xmlpath = os.path.split(os.path.realpath(__file__))[0] # Execution path xmlpath2 = xmlpath.split("src")[0] reportname = Autotest.newfile(xmlpath2 + "log/") f = open(reportname) txt = f.read() Autotest.mail("*****@*****.**", "Test Report", txt, reportname)