def start(): starttime = datetime.datetime.now() mtime = datetime.datetime.now().strftime("%Y%m%d") basdir = os.path.abspath(os.path.dirname(__file__)) path = os.path.join(os.path.join(os.getcwd(), 'test_case_data'), 'case.xlsx') listid, listkey, listconeent, listurl, listmethod, listqiwang, listname = datacel( path) listrelust, list_fail, list_pass, list_json, list_weizhi, listone = testinterface( ) filepath = os.path.join(os.path.join(basdir, 'test_Report'), '%s-result.xls' % mtime) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) save_result(starttime, len(listrelust), ((list_pass)), list_fail) create(filename=filepath, list_fail=list_fail, list_pass=list_pass, list_json=list_json, listurls=listurl, listkeys=listkey, listconeents=listconeent, listfangshis=listmethod, listqiwangs=listqiwang, listids=listid, listrelust=listrelust, listnames=listname)
def stast(): starttime = datetime.datetime.now() day = time.strftime("%Y%m%d%H%M", time.localtime(time.time())) basdir = os.path.abspath(os.path.dirname(__file__)) listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel( ) listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = testinterface( ) filepath = os.path.join(basdir + '\\test_Report\\%s-result.html' % day) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) save_result(starttime, len(listrelust), ((list_pass)), list_fail) endtime = datetime.datetime.now() createHtml(titles='接口测试报告', filepath=filepath, starttime=starttime, endtime=endtime, passge=list_pass, fail=list_fail, id=listid, name=listname, key=listkey, coneent=listconeent, url=listurl, meth=listfangshi, yuqi=listqiwang, json=list_json, relusts=listrelust, weizhi=list_weizhi, exceptions=list_exption)
def start_excel_report_http(): m = datetime.datetime.now().strftime("%Y%m%d") basdir = os.path.abspath(os.path.dirname(__file__)) path = os.getcwd() + '\\test_case_data\\case.xlsx' listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel( path) listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = testinterface( ) filepath = os.path.join(basdir + '\\test_Report\\%s-result.xls' % m) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) create(filename=filepath, list_fail=list_fail, list_pass=list_pass, list_json=list_json, listurls=listurl, listkeys=listkey, listconeents=listconeent, listfangshis=listfangshi, listqiwangs=listqiwang, listids=listid, listrelust=listrelust, listnames=listname) contec = 'dubbo接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( list_pass, list_fail, list_exption, list_weizhi, filepath) send_ding(content=contec)
def start_interface_html_http(): starttime=datetime.datetime.now() day= time.strftime("%Y%m%d%H%M", time.localtime(time.time())) basdir=os.path.abspath(os.path.dirname(__file__)) path = os.getcwd() + '/test_case_data/case.xlsx' listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel(path) listrelust, list_fail, list_pass, list_json,list_exption,list_weizhi = testinterface() filepath =os.path.join(basdir+'/test_Report/%s-result.html'%day) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) endtime=datetime.datetime.now() createHtml(titles=u'http接口自动化测试报告',filepath=filepath,starttime=starttime, endtime=endtime,passge=list_pass,fail=list_fail, id=listid,name=listname,key=listkey,coneent=listconeent,url=listurl,meth=listfangshi, yuqi=listqiwang,json=list_json,relusts=listrelust,weizhi=list_weizhi,exceptions=list_exption) #contec = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( #list_pass, list_fail, list_exption, list_weizhi, filepath) contec = relust(titles=u'http接口自动化测试报告',starttime=starttime, endtime=endtime,passge=list_pass,fail=list_fail, id=listid,name=listname,key=listkey,coneent=listconeent,url=listurl,meth=listfangshi, yuqi=listqiwang,json=list_json,relust=listrelust,weizhi=list_weizhi,exceptions=list_exption) send_email(contec,filepath)
def start_interface_html_http(): starttime = datetime.datetime.now() day = time.strftime("%Y%m%d%H%M", time.localtime(time.time())) basdir = os.path.abspath(os.path.dirname(__file__)) path = cf.CASE_PATH listid, listname, listisheader, listheader, listdata, listurl, listfangshi, listqiwang = datacel( path) listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = testinterface( ) filepath = os.path.join(basdir + '\\test_Report\\%s-result.html' % day) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) endtime = datetime.datetime.now() createHtml(titles=u'http接口自动化测试报告', filepath=filepath, starttime=starttime, endtime=endtime, passge=list_pass, fail=list_fail, id=listid, name=listname, is_header=listisheader, header=listheader, url=listurl, meth=listfangshi, yuqi=listqiwang, json=list_json, relusts=listrelust, weizhi=list_weizhi, exceptions=list_exption) contec = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( list_pass, list_fail, list_exption, list_weizhi, filepath) send_demo(contec)
def start(): starttime=datetime.datetime.now() m=datetime.datetime.now().strftime("%Y%m%d") basdir = os.path.abspath(os.path.dirname(__file__)) listid,listkey,listconeent,listurl,listfangshi,listqiwang,listname=datacel() listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi =testinterface() filepath = os.path.join(basdir + '\\test_Report\\%s-result.xls'%m) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) save_result(starttime, len(listrelust), ((list_pass)), list_fail) create(filename=filepath,list_fail=list_fail, list_pass=list_pass, list_json=list_json, listurls=listurl, listkeys=listkey,listconeents=listconeent, listfangshis=listfangshi, listqiwangs=listqiwang, listids=listid, listrelust=listrelust, listnames=listname)
def start_interface_html_http(): starttime = datetime.datetime.now() day = time.strftime("%Y%m%d%H%M", time.localtime(time.time())) basdir = os.path.abspath(os.path.dirname(__file__)) path = os.path.join(basdir, 'test_case_data') all_case = get_data(path) listrelust, list_fail, list_pass, list_json, list_exption, list_unknown = testinterface( all_case) filepath = os.path.join(basdir + '\\test_Report\\%s-result.html' % day) # if os.path.exists(filepath) is False: # os.system(r'touch %s' % filepath) endtime = datetime.datetime.now() listid = [] listname = [] listurl = [] listmethod = [] listexpect = [] listheader = [] listdata = [] for i in range(len(all_case)): listid.append(all_case[i]['id']) listname.append(all_case[i]['casename']) listurl.append(all_case[i]['url']) listmethod.append(all_case[i]['method']) listexpect.append(all_case[i]['expect']) listheader.append(all_case[i]['header']) listdata.append(all_case[i]['para']) createHtml(titles=u'http接口自动化测试报告', filepath=filepath, starttime=starttime, endtime=endtime, passge=list_pass, fail=list_fail, id=listid, name=listname, url=listurl, meth=listmethod, header=listheader, data=listdata, yuqi=listexpect, json=list_json, relusts=listrelust, unknown=list_unknown, exceptions=list_exption) contec = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( list_pass, list_fail, list_exption, list_unknown, filepath)
def start_interface_html_http(): starttime = datetime.datetime.now() day = time.strftime("%Y%m%d%H%M", time.localtime(time.time())) basdir = os.path.abspath(os.path.dirname(__file__)) path = os.getcwd() + '\\test_case_data\\case.xlsx' list_id, list_dec, list_param, list_url, list_method, list_expect, list_name = datacel( path) list_relust, list_fail, list_pass, list_json, list_exption, list_weizhi = testinterface( ) # 创建测试报告html文档 filepath = os.path.join(basdir + '\\test_Report\\%s-result.html' % day) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) endtime = datetime.datetime.now() createHtml(titles=u'http接口自动化测试报告', filepath=filepath, starttime=starttime, endtime=endtime, passge=list_pass, fail=list_fail, id=list_id, name=list_name, key=list_dec, coneent=list_param, url=list_url, meth=list_method, yuqi=list_expect, json=list_json, relusts=list_relust, weizhi=list_weizhi, exceptions=list_exption) contec = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s' % ( list_pass, list_fail, list_exption, list_weizhi) # 发送测试报告 email = Email() email.sendmail(content=contec, filepath=filepath)
def start_excel_report_http(): # m = datetime.datetime.now().strftime("%Y%m%d%H%M%S") m = datetime.datetime.now().strftime("%Y%m%d") basdir = os.path.abspath(os.path.dirname(__file__)) path = os.getcwd() + '\\test_case_data\\case.xlsx' listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel(path) listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = testinterface() filepath = os.path.join(basdir + '\\test_Report\\%s-result-us.xls' % m) if os.path.exists(filepath) is False: os.system(r'touch %s' % filepath) create(filename=filepath, list_fail=list_fail, list_pass=list_pass, list_json=list_json, listurls=listurl, listkeys=listkey, listconeents=listconeent, listfangshis=listfangshi, listqiwangs=listqiwang, listids=listid, listrelust=listrelust, listnames=listname) # 邮箱配置 sender = '*****@*****.**' psw = 'lovejt333' # 收件人多个时,中间用逗号隔开,如'[email protected],[email protected]' receiver = '*****@*****.**', '*****@*****.**', '*****@*****.**' # receiver_mail = {'mail': '[email protected], [email protected], [email protected]'} smtp_server = 'smtp.163.com' send_mail(sender, psw, receiver, smtp_server, filepath)