Skip to content

Commit

Permalink
�对部分地方进行优化
Browse files Browse the repository at this point in the history
  • Loading branch information
liwanlei committed Sep 3, 2018
1 parent b3bbc0b commit 5aa647d
Show file tree
Hide file tree
Showing 8 changed files with 925 additions and 122 deletions.
3 changes: 2 additions & 1 deletion config/config_T.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
@time: 2018/4/12 14:17
"""
Dingtalk_access_token=""
TestPlanUrl=''
TestPlanUrl=''
Config_Try_Num=3
10 changes: 0 additions & 10 deletions log/jiekou-2018-08-10-09.log

This file was deleted.

728 changes: 728 additions & 0 deletions log/jiekou-2018-09-03-21.log

Large diffs are not rendered by default.

Binary file removed python-hessian-1.0.2.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions run_http_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def start_interface_html_http():
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)
send_ding(content=contec)
#contec = u'http接口自动化测试完成,测试通过:%s,测试失败:%s,异常:%s,未知错误:%s,详情见:%s' % (
#list_pass, list_fail, list_exption, list_weizhi, filepath)
#send_ding(content=contec)
if __name__ == '__main__':
start_interface_html_http()
85 changes: 62 additions & 23 deletions testCase/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,84 @@
# @Author : lileilei
# @File : case.py
from Interface.testFengzhuang import TestApi
from Public.get_excel import datacel
from Public.log import LOG,logger
from Public.get_excel import datacel
from Public.log import LOG, logger
import os
path=os.getcwd()+'\\test_case_data\\case.xlsx'
listid,listkey,listconeent,listurl,listfangshi,listqiwang,listname=datacel(path)
from config.config_T import Config_Try_Num
path = os.getcwd() + '\\test_case_data\\case.xlsx'
listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel(path)
from Public.panduan import assert_in
@logger('测试')
def testinterface():
list_pass = 0
list_fail = 0
list_json = []
listrelust=[]
list_weizhi=0
list_exption=0
listrelust = []
list_weizhi = 0
list_exption = 0
error_num = 0
for i in range(len(listurl)):
api=TestApi(url=listurl[i],key=listkey[i],connent=listconeent[i],fangshi=listfangshi[i])
apijson=api.getJson()
if apijson['code']==0:
LOG.info('inputdata> 参数:%s, url:%s ,返回:%s,预期:%s'%(listconeent[i],listurl[i],apijson,listqiwang[i]))
assert_re=assert_in(asserqiwang=listqiwang[i],fanhuijson=apijson)
api = TestApi(url=listurl[i], key=listkey[i], connent=listconeent[i], fangshi=listfangshi[i])
apijson = api.getJson()
if error_num <= Config_Try_Num and error_num>=0:
if apijson['code'] == 0:
LOG.info('inputdata> 参数:%s, url:%s ,返回:%s,预期:%s' % (listconeent[i], listurl[i], apijson, listqiwang[i]))
assert_re = assert_in(asserqiwang=listqiwang[i], fanhuijson=apijson)
if assert_re['code'] == 0:
list_json.append(apijson['result'])
listrelust.append('pass')
list_pass += 1
error_num =0
i+=1
elif assert_re['code'] == 1:
list_fail += 1
listrelust.append('fail')
list_json.append(apijson['result'])
error_num +=1
i-=1
print('fail',i)
elif assert_re['code'] == 2:
list_exption += 1
listrelust.append('exception')
list_json.append(assert_re['result'])
error_num += 1
i-=1
else:
list_weizhi += 1
listrelust.append('未知错误')
list_json.append('未知错误')
error_num += 1
i-=1
else:
list_exption += 1
listrelust.append('exception')
list_json.append(apijson['result'])
error_num += 1
i-=1
else:
if apijson['code']==0:
LOG.info('inputdata> 参数:%s, url:%s ,返回:%s,预期:%s' % (listconeent[i], listurl[i], apijson, listqiwang[i]))
assert_re = assert_in(asserqiwang=listqiwang[i], fanhuijson=apijson)
if assert_re['code']==0:
list_json.append(apijson['result'])
listrelust.append('pass')
list_pass += 1
elif assert_re['code']==1:
list_fail+=1
error_num = 0
elif assert_re['code'] == 1:
list_fail += 1
listrelust.append('fail')
list_json.append(apijson['result'])
elif assert_re['code']==2:
list_exption+=1
error_num = 0
elif assert_re['code'] == 2:
list_exption += 1
listrelust.append('exception')
list_json.append(assert_re['result'])
error_num = 0
else:
list_weizhi+=1
list_weizhi += 1
listrelust.append('未知错误')
list_json.append('未知错误')
else:
list_exption += 1
listrelust.append('exception')
list_json.append(apijson['result'])
continue
return listrelust,list_fail,list_pass,list_json,list_exption,list_weizhi
error_num = 0
i-=1
print('i+1',i)
return listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi
85 changes: 0 additions & 85 deletions test_Report/201806211302-result.html

This file was deleted.

130 changes: 130 additions & 0 deletions test_Report/201809032125-result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!DOCTYPE html>
<html>
<head>
<title>http接口自动化测试报告</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 Bootstrap -->
<link href="https://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 Shim 和 Respond.js 用于让 IE8 支持 HTML5元素和媒体查询 -->
<!-- 注意: 如果通过 file:// 引入 Respond.js 文件,则该文件无法起效果 -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<style type="text/css">
.hidden-detail,.hidden-tr{
display:none;
}
</style>
</head>
<body>

<div class='col-md-4 col-md-offset-4' style='margin-left:3%;'>
<h1>接口测试的结果</h1>
<table class="table table-hover table-condensed">
<tbody>
<tr>
<td><strong>开始时间:</strong> 2018-09-03 21:25:58.695376</td>
</tr>
<td><strong>结束时间:</strong> 2018-09-03 21:25:59.179404</td></tr>
<td><strong>耗时:</strong> 0:00:00.484028</td></tr>
<td><strong>结果:</strong>
<span >Pass: <strong >0</strong>
Fail: <strong >2</strong>
exception: <strong >1</strong>
weizhicuowu : <strong >0</strong></span></td>
</tr>
</tbody></table>
</div> <div class="row " style="margin:60px">
<div style=' margin-top: 18%;' >
<div class="btn-group" role="group" aria-label="...">
<button type="button" id="check-all" class="btn btn-primary">所有用例</button>
<button type="button" id="check-success" class="btn btn-success">成功用例</button>
<button type="button" id="check-danger" class="btn btn-danger">失败用例</button>
<button type="button" id="check-warning" class="btn btn-warning">错误用例</button>
<button type="button" id="check-except" class="btn btn-defult">异常用例</button>
</div>
<div class="btn-group" role="group" aria-label="...">
</div>
<table class="table table-hover table-condensed table-bordered" style="word-wrap:break-word; word-break:break-all; margin-top: 7px;">
<tr >
<td ><strong>用例ID&nbsp;</strong></td>
<td><strong>用例名字</strong></td>
<td><strong>key</strong></td>
<td><strong>请求内容</strong></td>
<td><strong>url</strong></td>
<td><strong>请求方式</strong></td>
<td><strong>预期</strong></td>
<td><strong>实际返回</strong></td>
<td><strong>结果</strong></td>
</tr>

<tr class="case-tr warning">
<td>1.0</td>
<td>图灵api接口</td>
<td>aaaa</td>
<td>{'password':'1222'}</td>
<td>http://www.tuling123.com/openapi/api</td>
<td>POST</td>
<td>code=40001</td>
<td>{'code': 40007, 'text': '您的请求内容为空。'}</td>
<td bgcolor="fail">fail</td>
</tr>

<tr class="case-tr warning">
<td>2.0</td>
<td>图灵api接口</td>
<td>dfeb1cc8125943d29764a2f2f5c33739</td>
<td>{'password':'1222'}</td>
<td>http://www.tuling123.com/openapi/api
</td>
<td>POST</td>
<td>code=40002</td>
<td>{'code': 40007, 'text': '您的请求内容为空。'}</td>
<td bgcolor="fail">fail</td>
</tr>

<tr class="case-tr error">
<td>3.0</td>
<td>豆瓣api</td>
<td>dfeb1cc8125943d29764a2f2f5c33739</td>
<td>{'password':'1222'}</td>
<td>https://api.douban.com/v2/photo/:id</td>
<td>GET</td>
<td></td>
<td>填写测试预期值</td>
<td bgcolor="crimson">exect</td>
</tr>
</div></div></table><script src="https://code.jquery.com/jquery.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script type="text/javascript">
$("#check-danger").click(function(e){
$(".case-tr").removeClass("hidden-tr");
$(".success").addClass("hidden-tr");
$(".warning").addClass("hidden-tr");
$(".error").addClass("hidden-tr");
});
$("#check-warning").click(function(e){
$(".case-tr").removeClass("hidden-tr");
$(".success").addClass("hidden-tr");
$(".danger").addClass("hidden-tr");
$(".error").addClass("hidden-tr");
});
$("#check-success").click(function(e){
$(".case-tr").removeClass("hidden-tr");
$(".warning").addClass("hidden-tr");
$(".danger").addClass("hidden-tr");
$(".error").addClass("hidden-tr");
});
$("#check-except").click(function(e){
$(".case-tr").removeClass("hidden-tr");
$(".warning").addClass("hidden-tr");
$(".danger").addClass("hidden-tr");
$(".success").addClass("hidden-tr");
});
$("#check-all").click(function(e){
$(".case-tr").removeClass("hidden-tr");
});
</script>
</body></html>

0 comments on commit 5aa647d

Please sign in to comment.