Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def create_Html():
    filepath = './report/' + now + '-relult.html'
    code = filepath.split('relult')[1]
    endtime = datetime.datetime.now()
    if os.path.exists(filepath) is True:
        os.remove(filepath)
    if os.path.exists(filepath) is False:
        f = open(filepath, 'w')
        f.close()

    createHtml(titles='白菜的测试报告',
               filepath=filepath,
               starttime=starttime,
               endtime=endtime,
               passge=list_pass,
               fail=list_fail,
               id=listids,
               name=listnames,
               key=listkeys,
               coneent=listconeents,
               url=listurls,
               meth=listfangshis,
               yuqi=listqiwangs,
               json=list_json,
               relusts=listrelust)
    return filepath, code
Exemplo n.º 4
0
def Run_interface_Test():
    '''执行测试'''
    starttime = datetime.datetime.now()

    listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = read(
        test_case_data)
    listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi = testinterface(
    )

    if os.path.exists(Report) is False:
        os.system(r'touch %s' % Report)

    endtime = datetime.datetime.now()

    createHtml(titles=report_title,
               filepath=Report,
               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)
Exemplo n.º 5
0
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(os.path.join(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(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)
Exemplo n.º 6
0
def stast():
    starttime = datetime.datetime.now()
    suite = unittest.TestSuite()
    suite.addTest(Testinface("testinterface"))
    me = Testinface()
    list_fail, list_pass, list_json, listurls, listkeys, listconeents, listfangshis, listqiwangs, listids, listrelust, listnames = me.testinterface(
    )
    filepath = r'C:\Users\Administrator\Desktop\jiejko\test_Report\relult.html'
    if os.path.exists(filepath) is False:
        os.system(r'touch %s' % filepath)
    endtime = datetime.datetime.now()
    createHtml(titles='接口测试报告',
               filepath=filepath,
               starttime=starttime,
               endtime=endtime,
               passge=list_pass,
               fail=list_fail,
               id=listids,
               name=listnames,
               key=listkeys,
               coneent=listconeents,
               url=listurls,
               meth=listfangshis,
               yuqi=listqiwangs,
               json=list_json,
               relusts=listrelust)
Exemplo n.º 7
0
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)
Exemplo n.º 8
0
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() + '\\data\\case.xlsx'
    print(path)
    listid, listname, listmethod, listurl, listkey, listparams, listanticipate = dataParsing(
        path)
    listrelust, list_fail, list_pass, list_json, list_abnormal, list_unknown = caseInterface(
    )
    filepath = os.path.join(basdir + '\\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=listparams,
               url=listurl,
               meth=listmethod,
               yuqi=listanticipate,
               json=list_json,
               relusts=listrelust,
               weizhi=list_unknown,
               exceptions=list_abnormal)
    contec_messages = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % (
        list_pass, list_fail, list_abnormal, list_unknown, filepath)
    try:
        send_ding(content=contec_messages)
    except:
        print("钉钉发送消息失败")
    try:
        open(filepath)
        wechatSendmessages(msg=contec_messages + filepath)
    except:
        print("企业微信消息发送失败")
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
这里你可以分开执行上面你case里面包含的用例。也可以单独执行里面的某一个的测试用例。
'''
from Public import BSTestRunner
from Interface.Email import sendmail
if __name__ == '__main__':
    starttime = datetime.datetime.now()
    suite = unittest.TestSuite()
    suite.addTest(Testinface("testinterface"))
    me = Testinface()
    list_fail, list_pass, list_json, listurls, list_keys, listconeents, listfangshis, listqiwangs, listids, listrelust, listnames = me.testinterface(
    )
    filepath = r'D:\\software\\Python\\workspace\\InterfaceTest\\report\\pyresult.html'
    if os.path.exists(filepath) is False:
        os.system(r'touch %s' % filepath)
    endtime = datetime.datetime.now()
    createHtml(titles='接口测试报告',
               filepath=filepath,
               starttime=starttime,
               endtime=endtime,
               passge=list_pass,
               fail=list_fail,
               id=listids,
               name=listnames,
               key=list_keys,
               coneent=listconeents,
               url=listurls,
               meth=listfangshis,
               yuqi=listqiwangs,
               json=list_json,
               relusts=listrelust)
    sendmail(filepath)