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_dubbo_case(): 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\\dubbocase.xlsx' listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel( path) listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = testdubbointerface( ) 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='dubbo接口自动化测试报告', 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 = 'dubbo接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % ( list_pass, list_fail, list_exption, list_weizhi, filepath) send_ding(content=contec)
# -*- coding: utf-8 -*- # @Author : leizi from testCase.ddt_case import MyTest import unittest, time, os from Public import BSTestRunner from Public.Dingtalk import send_ding if __name__ == '__main__': suite = unittest.TestSuite() suite.addTests(unittest.TestLoader().loadTestsFromTestCase(MyTest)) now = time.strftime('%Y-%m%d', time.localtime(time.time())) basedir = os.path.abspath(os.path.dirname(__file__)) file_dir = os.path.join(basedir, 'test_Report') file = os.path.join(file_dir, (now + '.html')) re_open = open(file, 'wb') runner = BSTestRunner.BSTestRunner(stream=re_open, title='http接口测试报告', description='测试结果') m = runner.run(suite) contec = 'http接口自动化测试完成,测试通过:%s,测试失败:%s,未知错误:%s,详情见:%s' % ( m.success_count, m.failure_count, m.error_count, file) send_ding(content=contec)