修复bug

This commit is contained in:
liwanlei
2018-02-27 12:32:30 +08:00
parent 20f4dfb4eb
commit 8554dbe4cd
6 changed files with 461 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ class TestApi(object):
response=reques.post(self.url,self.parem)
elif self.fangshi=="GET":
self.parem = {'key': self.key, 'info': self.connent}
response = reques.get(self.url,self.parem)
response = reques.get(url=self.url,params=self.parem)
return response
def getcode(self):
code=self.testapi()['code']

View File

@@ -1 +1 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

View File

@@ -0,0 +1,66 @@
[2018-02-27 12:18:25.241308] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:18:25.929347] INFO: jiekou: 当前模块 生成数据驱动所用数据
[2018-02-27 12:18:25.929347] INFO: jiekou: 当前模块 解析测试用例文件
[2018-02-27 12:18:25.971350] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:18:25.971350] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api,key:aaaa,参数:sasa,请求方式POST
[2018-02-27 12:18:25.971350] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api,key:aaaa,参数:sasa,请求方式None
[2018-02-27 12:18:26.007352] INFO: jiekou: 返回结果:{'code': 40001, 'text': '亲爱的key不对哦。'}
[2018-02-27 12:18:26.007352] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:18:26.008352] INFO: jiekou: 测试用例执行完毕
[2018-02-27 12:18:26.008352] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:18:26.008352] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api
,key:dfeb1cc8125943d29764a2f2f5c33739,参数:,请求方式POST
[2018-02-27 12:18:26.008352] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api
,key:dfeb1cc8125943d29764a2f2f5c33739,参数:,请求方式None
[2018-02-27 12:18:26.036353] INFO: jiekou: 返回结果:{'code': 40002, 'text': '有什么话不方便说嘛?'}
[2018-02-27 12:18:26.037353] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:18:26.037353] INFO: jiekou: 测试用例执行完毕
[2018-02-27 12:18:26.037353] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:18:26.037353] INFO: jiekou: 输入参数url:https://api.douban.com/v2/photo/:id,key:,参数:,请求方式GET
[2018-02-27 12:18:26.037353] INFO: jiekou: 输入参数url:https://api.douban.com/v2/photo/:id,key:,参数:,请求方式None
[2018-02-27 12:18:26.037353] INFO: jiekou: 测试用例执行完毕
[2018-02-27 12:19:15.172164] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:19:22.963609] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:20:17.034702] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:20:21.772973] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:20:21.844977] INFO: jiekou: 当前模块 生成数据驱动所用数据
[2018-02-27 12:20:21.845977] INFO: jiekou: 当前模块 解析测试用例文件
[2018-02-27 12:20:21.860978] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:20:21.860978] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api,key:aaaa,参数:sasa,请求方式POST
[2018-02-27 12:20:21.860978] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api,key:aaaa,参数:sasa,请求方式None
[2018-02-27 12:20:21.889980] INFO: jiekou: 返回结果:{'code': 40001, 'text': '亲爱的key不对哦。'}
[2018-02-27 12:20:21.889980] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:20:21.889980] INFO: jiekou: 测试用例执行完毕
[2018-02-27 12:20:21.890980] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:20:21.890980] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api
,key:dfeb1cc8125943d29764a2f2f5c33739,参数:,请求方式POST
[2018-02-27 12:20:21.890980] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api
,key:dfeb1cc8125943d29764a2f2f5c33739,参数:,请求方式None
[2018-02-27 12:20:21.919982] INFO: jiekou: 返回结果:{'code': 40002, 'text': 'what?'}
[2018-02-27 12:20:21.919982] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:20:21.920982] INFO: jiekou: 测试用例执行完毕
[2018-02-27 12:20:21.920982] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:20:21.920982] INFO: jiekou: 输入参数url:https://api.douban.com/v2/photo/:id,key:,参数:,请求方式GET
[2018-02-27 12:20:21.920982] INFO: jiekou: 输入参数url:https://api.douban.com/v2/photo/:id,key:,参数:,请求方式None
[2018-02-27 12:20:21.920982] INFO: jiekou: 测试用例执行完毕
[2018-02-27 12:30:17.375040] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:30:17.419042] INFO: jiekou: 当前模块 解析测试用例文件
[2018-02-27 12:30:17.447044] INFO: jiekou: 当前模块 解析测试用例文件
[2018-02-27 12:30:17.451044] INFO: jiekou: 当前模块 测试
[2018-02-27 12:30:17.516048] INFO: jiekou: inputdata> 参数:sasa, url:http://www.tuling123.com/openapi/api ,返回:{'code': 40001, 'text': '亲爱的key不对哦。'},预期:code=40001
[2018-02-27 12:30:17.517048] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:30:17.572051] INFO: jiekou: inputdata> 参数:, url:http://www.tuling123.com/openapi/api
,返回:{'code': 40002, 'text': '你想说什么就直说,不用藏在心里哈~'},预期:code=40002
[2018-02-27 12:30:17.572051] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:31:33.235379] INFO: jiekou: 当前模块 requests封装
[2018-02-27 12:31:33.279381] INFO: jiekou: 当前模块 解析测试用例文件
[2018-02-27 12:31:33.299382] INFO: jiekou: 当前模块 解析测试用例文件
[2018-02-27 12:31:33.302382] INFO: jiekou: 当前模块 测试
[2018-02-27 12:31:33.361386] INFO: jiekou: inputdata> 参数:sasa, url:http://www.tuling123.com/openapi/api ,返回:{'code': 40001, 'text': '亲爱的key不对哦。'},预期:code=40001
[2018-02-27 12:31:33.361386] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:31:33.426390] INFO: jiekou: inputdata> 参数:, url:http://www.tuling123.com/openapi/api
,返回:{'code': 40002, 'text': '是不是有什么难言之隐呢?'},预期:code=40002
[2018-02-27 12:31:33.427390] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:31:33.661403] INFO: jiekou: inputdata> 参数:, url:https://api.douban.com/v2/photo/:id ,返回:{'msg': 'uri_not_found', 'code': 1001, 'request': 'GET /v2/photo/:id'},预期:code=1001&msg=uri_not_found
[2018-02-27 12:31:33.662403] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:31:33.745408] INFO: jiekou: 当前模块 保存测试结果

View File

@@ -1,2 +1,3 @@
记录测试时间测试总数pass数量失败数量 用‘=’拼接
2017-10-16 20:54:56.323951=3=3=0
2018-02-27 12:31:33.299382=3=3=0

306
test_Report/2018-0227.html Normal file
View File

@@ -0,0 +1,306 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>接口测试报告</title>
<meta name="generator" content="BSTestRunner 0.8.4"/>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
<style type="text/css" media="screen">
/* -- css div popup ------------------------------------------------------------------------ */
.popup_window {
display: none;
position: relative;
left: 0px;
top: 0px;
/*border: solid #627173 1px; */
padding: 10px;
background-color: #99CCFF;
font-family: "Lucida Console", "Courier New", Courier, monospace;
text-align: left;
font-size: 10pt;
width: 1200px;
}
/* -- report ------------------------------------------------------------------------ */
#show_detail_line .label {
font-size: 85%;
cursor: pointer;
}
#show_detail_line {
margin: 2em auto 1em auto;
}
#total_row { font-weight: bold; }
.hiddenRow { display: none; }
.testcase { margin-left: 2em; }
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<script language="javascript" type="text/javascript"><!--
output_list = Array();
/* level - 0:Summary; 1:Failed; 2:All */
function showCase(level) {
trs = document.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
tr = trs[i];
id = tr.id;
if (id.substr(0,2) == 'ft') {
if (level < 1) {
tr.className = 'hiddenRow';
}
else {
tr.className = '';
}
}
if (id.substr(0,2) == 'pt') {
if (level > 1) {
tr.className = '';
}
else {
tr.className = 'hiddenRow';
}
}
}
}
function showClassDetail(cid, count) {
var id_list = Array(count);
var toHide = 1;
for (var i = 0; i < count; i++) {
tid0 = 't' + cid.substr(1) + '.' + (i+1);
tid = 'f' + tid0;
tr = document.getElementById(tid);
if (!tr) {
tid = 'p' + tid0;
tr = document.getElementById(tid);
}
id_list[i] = tid;
if (tr.className) {
toHide = 0;
}
}
for (var i = 0; i < count; i++) {
tid = id_list[i];
if (toHide) {
document.getElementById('div_'+tid).style.display = 'none'
document.getElementById(tid).className = 'hiddenRow';
}
else {
document.getElementById(tid).className = '';
}
}
}
function showTestDetail(div_id){
var details_div = document.getElementById(div_id)
var displayState = details_div.style.display
// alert(displayState)
if (displayState != 'block' ) {
displayState = 'block'
details_div.style.display = 'block'
}
else {
details_div.style.display = 'none'
}
}
function html_escape(s) {
s = s.replace(/&/g,'&amp;');
s = s.replace(/</g,'&lt;');
s = s.replace(/>/g,'&gt;');
return s;
}
/* obsoleted by detail in <div>
function showOutput(id, name) {
var w = window.open("", //url
name,
"resizable,scrollbars,status,width=800,height=450");
d = w.document;
d.write("<pre>");
d.write(html_escape(output_list[id]));
d.write("\n");
d.write("<a href='javascript:window.close()'>close</a>\n");
d.write("</pre>\n");
d.close();
}
*/
--></script>
<div class="container">
<div class='heading'>
<h1>接口测试报告</h1>
<p><strong>Start Time:</strong> 2018-02-27 12:20:21</p>
<p><strong>Duration:</strong> 0:00:00.061004</p>
<p><strong>Status:</strong> <span class="text text-success">Pass <strong>2</strong></span> <span class="text text-warning">Error <strong>1</strong></span></p>
<p class='description'>测试结果</p>
</div>
<p id='show_detail_line'>
<span class="label label-primary" onclick="showCase(0)">Summary</span>
<span class="label label-danger" onclick="showCase(1)">Failed</span>
<span class="label label-default" onclick="showCase(2)">All</span>
</p>
<table id='result_table' class="table">
<thead>
<tr id='header_row'>
<th>Test Group/Test case</td>
<th>Count</td>
<th>Pass</td>
<th>Fail</td>
<th>Error</td>
<th>View</td>
</tr>
</thead>
<tbody>
<tr class='text text-warning'>
<td>testCase.ddt_case.MyTest</td>
<td>3</td>
<td>2</td>
<td>0</td>
<td>1</td>
<td><a class="btn btn-xs btn-primary"href="javascript:showClassDetail('c1',3)">Detail</a></td>
</tr>
<tr id='pt1.1' class='hiddenRow'>
<td class='text text-success'><div class='testcase'>test_api_1</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link btn btn-xs btn-default" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.1')" >
pass</a>
<div id='div_pt1.1' class="popup_window">
<div style='text-align: right;cursor:pointer'>
<a onfocus='this.blur();' onclick="document.getElementById('div_pt1.1').style.display = 'none' " >
[x]</a>
</div>
<pre>
pt1.1: [2018-02-27 12:20:21.860978] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:20:21.860978] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api,key:aaaa,参数:sasa,请求方式POST
[2018-02-27 12:20:21.860978] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api,key:aaaa,参数:sasa,请求方式None
[2018-02-27 12:20:21.889980] INFO: jiekou: 返回结果:{'code': 40001, 'text': '亲爱的key不对哦。'}
[2018-02-27 12:20:21.889980] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:20:21.889980] INFO: jiekou: 测试用例执行完毕
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='pt1.2' class='hiddenRow'>
<td class='text text-success'><div class='testcase'>test_api_2</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link btn btn-xs btn-default" onfocus='this.blur();' href="javascript:showTestDetail('div_pt1.2')" >
pass</a>
<div id='div_pt1.2' class="popup_window">
<div style='text-align: right;cursor:pointer'>
<a onfocus='this.blur();' onclick="document.getElementById('div_pt1.2').style.display = 'none' " >
[x]</a>
</div>
<pre>
pt1.2: [2018-02-27 12:20:21.890980] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:20:21.890980] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api
,key:dfeb1cc8125943d29764a2f2f5c33739,参数:,请求方式POST
[2018-02-27 12:20:21.890980] INFO: jiekou: 输入参数url:http://www.tuling123.com/openapi/api
,key:dfeb1cc8125943d29764a2f2f5c33739,参数:,请求方式None
[2018-02-27 12:20:21.919982] INFO: jiekou: 返回结果:{'code': 40002, 'text': 'what?'}
[2018-02-27 12:20:21.919982] INFO: jiekou: 当前模块 断言测试结果
[2018-02-27 12:20:21.920982] INFO: jiekou: 测试用例执行完毕
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
<tr id='ft1.3' class='none'>
<td class='text text-warning'><div class='testcase'>test_api_3</div></td>
<td colspan='5' align='center'>
<!--css div popup start-->
<a class="popup_link btn btn-xs btn-default" onfocus='this.blur();' href="javascript:showTestDetail('div_ft1.3')" >
error</a>
<div id='div_ft1.3' class="popup_window">
<div style='text-align: right;cursor:pointer'>
<a onfocus='this.blur();' onclick="document.getElementById('div_ft1.3').style.display = 'none' " >
[x]</a>
</div>
<pre>
ft1.3: [2018-02-27 12:20:21.920982] INFO: jiekou: 测试用例开始执行
[2018-02-27 12:20:21.920982] INFO: jiekou: 输入参数url:https://api.douban.com/v2/photo/:id,key:,参数:,请求方式GET
[2018-02-27 12:20:21.920982] INFO: jiekou: 输入参数url:https://api.douban.com/v2/photo/:id,key:,参数:,请求方式None
[2018-02-27 12:20:21.920982] INFO: jiekou: 测试用例执行完毕
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Roaming\Python\Python36\site-packages\ddt.py", line 139, in wrapper
return func(self, *args, **kwargs)
File "C:\Users\Administrator\Desktop\jiekou-python3\testCase\ddt_case.py", line 17, in test_api
apijson = api.getJson()
File "C:\Users\Administrator\Desktop\jiekou-python3\Interface\testFengzhuang.py", line 27, in getJson
json_data = self.testapi()
File "C:\Users\Administrator\Desktop\jiekou-python3\Interface\testFengzhuang.py", line 21, in testapi
response = reques.get(self.url,self.parem)
TypeError: get() takes 2 positional arguments but 3 were given
</pre>
</div>
<!--css div popup end-->
</td>
</tr>
</tbody>
<tfoot>
<tr id='total_row'>
<td>Total</td>
<td>3</td>
<td class="text text-success">2</td>
<td class="text text-danger">0</td>
<td class="text text-warning">1</td>
<td>&nbsp;</td>
</tr>
</tfoot>
</table>
<div id='ending'>&nbsp;</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>接口测试报告</title>
<style type="text/css">
td{ width:40px; height:50px;}
</style>
</head>
<body>
<div style='width: 1170px;margin-left: 15%'>
<h1>接口测试的结果</h1>
<p><strong>开始时间:</strong> 2018-02-27 12:31:33.299382</p>
<p><strong>结束时间:</strong> 2018-02-27 12:31:33.747408</p>
<p><strong>耗时:</strong> 0:00:00.448026</p>
<p><strong>结果:</strong>
<span >Pass: <strong >3</strong>
Fail: <strong >0</strong>
</span></p>
<p ><strong>测试详情如下</strong></p> </div>
<p>&nbsp;</p>
<table border='2'cellspacing='1' cellpadding='1' width='1100'align="center" >
<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>
<td>1.0</td>
<td>图灵api接口</td>
<td>aaaa</td>
<td>sasa
</td>
<td>http://www.tuling123.com/openapi/api</td>
<td>POST</td>
<td>code=40001</td>
<td>{'code': 40001, 'text': '亲爱的key不对哦。'}</td>
<td bgcolor="green">pass</td>
</tr>
<tr>
<td>2.0</td>
<td>图灵api接口</td>
<td>dfeb1cc8125943d29764a2f2f5c33739</td>
<td>
</td>
<td>http://www.tuling123.com/openapi/api
</td>
<td>POST</td>
<td>code=40002</td>
<td>{'code': 40002, 'text': '是不是有什么难言之隐呢?'}</td>
<td bgcolor="green">pass</td>
</tr>
<tr>
<td>3.0</td>
<td>豆瓣api</td>
<td></td>
<td>
</td>
<td>https://api.douban.com/v2/photo/:id</td>
<td>GET</td>
<td>code=1001&msg=uri_not_found</td>
<td>{'msg': 'uri_not_found', 'code': 1001, 'request': 'GET /v2/photo/:id'}</td>
<td bgcolor="green">pass</td>
</tr>
</table>
</body>
</html>