修改bug

This commit is contained in:
lileilei
2020-11-22 11:23:42 +08:00
parent 45dfe94021
commit 96e5b850aa
30 changed files with 42 additions and 148 deletions

View File

@@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">

2
.idea/misc.xml generated
View File

@@ -3,5 +3,5 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -2,11 +2,11 @@
# @Time : 2017/6/4 20:35
# @Author : lileilei
# @File : get_excel.py
import xlrd
import xlrd,os
from Public.log import LOG, logger
@logger('解析测试用例文件')
# @logger('解析测试用例文件')
def datacel(filrpath):
try:
file = xlrd.open_workbook(filrpath)
@@ -34,7 +34,8 @@ def datacel(filrpath):
return
@logger('生成数据驱动所用数据')
def makedata():
listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname=datacel()
path = os.getcwd() + '//test_case_data//case.xlsx'
listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname=datacel(path)
i=0
make_data=[]
for i in range(len(listid)):

View File

@@ -56,7 +56,7 @@ def yangshique(me):
def create(filename, list_pass, list_fail, listids, listnames, listkeys, listconeents, listurls, listfangshis,
listqiwangs, list_json, listrelust):
filepath = open(r'.\config\test_report.yaml', encoding='utf-8')
filepath = open(r'./config/test_report.yaml', encoding='utf-8')
file_config = yaml.load(filepath)
file = Workbook(filename)
table = file.add_sheet('测试结果', cell_overwrite_ok=True)

View File

@@ -4,6 +4,7 @@
## qq交流群194704520  
### 使用的库 requests绝大部分是基于Python原有的库进行的这样简单方便
### 使用脚本参数分离等思想,尽可能降低代码的耦合度。
### 如果你不配置钉钉机器人,注释到机器人相关的代码
# 首先我们来看下我们的目录
##
![Alt text](https://github.com/liwanlei/jiekou-python3/blob/master/img/xiangmujiegoutu.png)

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,24 @@
[2020-11-22 11:22:16.519830] INFO: jiekou: 当前模块 requests封装
[2020-11-22 11:22:16.520192] INFO: jiekou: 全部args参数参数信息 , ()
[2020-11-22 11:22:16.520296] INFO: jiekou: 全部kwargs参数信息 , {}
[2020-11-22 11:22:16.565993] INFO: jiekou: 当前模块 生成数据驱动所用数据
[2020-11-22 11:22:16.566186] INFO: jiekou: 全部args参数参数信息 , ()
[2020-11-22 11:22:16.566293] INFO: jiekou: 全部kwargs参数信息 , {}
[2020-11-22 11:22:16.587815] INFO: jiekou: 测试用例开始执行
[2020-11-22 11:22:16.587974] INFO: jiekou: 输入参数url:/openapi/api,key:aaaa,参数:{'password':'1222'},请求方式POST
[2020-11-22 11:22:16.588069] INFO: jiekou: 输入参数url:/openapi/api,key:aaaa,参数:{'password':'1222'},请求方式None
[2020-11-22 11:22:16.589757] INFO: jiekou: post请求出错出错原因:Invalid URL '/openapi/api': No schema supplied. Perhaps you meant http:///openapi/api?
[2020-11-22 11:22:16.590439] INFO: jiekou: 返回结果:{'code': 1, 'result': "post请求出错出错原因:Invalid URL '/openapi/api': No schema supplied. Perhaps you meant http:///openapi/api?"}
[2020-11-22 11:22:16.590706] INFO: jiekou: 当前模块 断言测试结果
[2020-11-22 11:22:16.590836] INFO: jiekou: 全部args参数参数信息 , ()
[2020-11-22 11:22:16.590936] INFO: jiekou: 全部kwargs参数信息 , {'asserqingwang': 'code=40001'}
[2020-11-22 11:22:16.591054] INFO: jiekou: 测试用例执行完毕
[2020-11-22 11:22:16.591211] INFO: jiekou: 测试用例开始执行
[2020-11-22 11:22:16.591322] INFO: jiekou: 输入参数url:/openapi/api,key:dfeb1cc8125943d29764a2f2f5c33739,参数:{'password':'1222'},请求方式POST
[2020-11-22 11:22:16.591412] INFO: jiekou: 输入参数url:/openapi/api,key:dfeb1cc8125943d29764a2f2f5c33739,参数:{'password':'1222'},请求方式None
[2020-11-22 11:22:16.591800] INFO: jiekou: post请求出错出错原因:Invalid URL '/openapi/api': No schema supplied. Perhaps you meant http:///openapi/api?
[2020-11-22 11:22:16.591918] INFO: jiekou: 返回结果:{'code': 1, 'result': "post请求出错出错原因:Invalid URL '/openapi/api': No schema supplied. Perhaps you meant http:///openapi/api?"}
[2020-11-22 11:22:16.592009] INFO: jiekou: 当前模块 断言测试结果
[2020-11-22 11:22:16.592090] INFO: jiekou: 全部args参数参数信息 , ()
[2020-11-22 11:22:16.592170] INFO: jiekou: 全部kwargs参数信息 , {'asserqingwang': 'code=40002'}
[2020-11-22 11:22:16.592265] INFO: jiekou: 测试用例执行完毕

View File

@@ -1,2 +1,6 @@
记录测试时间测试总数pass数量失败数量 用‘=’拼接
2017-10-16 20:54:56.323951=3=3=0
2020-11-22 11:19:17.653613=2=0=2
2020-11-22 11:19:55.276935=2=0=2
2020-11-22 11:20:03.408231=2=0=2
2020-11-22 11:20:22.107504=2=0=2

View File

@@ -11,7 +11,7 @@ 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'
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)

View File

@@ -16,8 +16,8 @@ def stast():
path = os.getcwd() + '//test_case_data//case.xlsx'
basdir = os.path.abspath(os.path.dirname(__file__))
listid, listkey, listconeent, listurl, listfangshi, listqiwang, listname = datacel(path)
listrelust, list_fail, list_pass, list_json = testinterface()
filepath = os.path.join(basdir + '\\test_Report\\%s-result.html' % day)
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)
@@ -25,7 +25,7 @@ def stast():
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)
yuqi=listqiwang, json=list_json, relusts=listrelust,exceptions=list_exption,weizhi=list_weizhi)
# sendemali(filepath)

View File

@@ -16,7 +16,7 @@ def start_interface_html_http():
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)
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()
@@ -26,7 +26,7 @@ def start_interface_html_http():
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)
# send_ding(content=contec)
if __name__ == '__main__':

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,136 +0,0 @@
<!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-04 11:48:05.475301</td>
</tr>
<td><strong>结束时间:</strong> 2018-09-04 11:48:13.579765</td>
</tr>
<td><strong>耗时:</strong> 0:00:08.104464</td>
</tr>
<td><strong>结果:</strong>
<span>Pass: <strong>0</strong>
Fail: <strong>0</strong>
exception: <strong>2</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 error">
<td>1.0</td>
<td>图灵api接口</td>
<td>aaaa</td>
<td>{'password':'1222'}</td>
<td>/openapi/api</td>
<td>POST</td>
<td>code=40001</td>
<td>post请求出错出错原因:HTTPConnectionPool(host='127.0.0.1', port=8888): Max retries exceeded with url:
http://www.tuling123.com/openapi/api?%7B%22key%22:%20%22aaaa%22,%20%22info%22:%20%22%7B'password':'1222'%7D%22%7D
(Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('
<urllib3.connection.HTTPConnection object at 0x00000000035C5BA8>: Failed to establish a new
connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。',)))
</td>
<td bgcolor="crimson">exect</td>
</tr>
<tr class="case-tr error">
<td>2.0</td>
<td>图灵api接口</td>
<td>dfeb1cc8125943d29764a2f2f5c33739</td>
<td>{'password':'1222'}</td>
<td>/openapi/api</td>
<td>POST</td>
<td>code=40002</td>
<td>post请求出错出错原因:HTTPConnectionPool(host='127.0.0.1', port=8888): Max retries exceeded with url:
http://www.tuling123.com/openapi/api?%7B%22key%22:%20%22dfeb1cc8125943d29764a2f2f5c33739%22,%20%22info%22:%20%22%7B'password':'1222'%7D%22%7D
(Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('
<urllib3.connection.HTTPConnection object at 0x000000000481D198>: Failed to establish a new
connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。',)))
</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>