生成htmlreport的模块是我在网上随意找的一个版本,主要生成的report包括接口名称,接口url,请求数据,响应数据,断言词,断言结果等

具体的htmlreport代码如下:

# -*- encoding:utf-8 -*-

from bottle import template

def report_html(data,html_name):
template_demo = """
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.hovertable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #999999;
border-collapse: collapse;
}
table.hovertable th {
background-color:#ff6347;
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
table.hovertable tr {
background-color:#d4e3e5;
}
table.hovertable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #a9c6c9;
}
</style> <!-- Table goes in the document BODY --> <head> <meta http-equiv="content-type" content="txt/html; charset=utf-8" /> </head> <table class="hovertable">
<tr>
<th>接口名称</th><th>接口 URL</th><th>请求数据</th><th>接口响应数据</th><th>接口调用耗时(单位:ms)</th><th>断言表</th><th>测试结果</th>
</tr>
% for name,url,request_data,response_data,test_time,assert_word,result in items:
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';"> <td>{{name}}</td><td>{{url}}</td><td>{{request_data}}</td><td>{{response_data}}</td><td>{{test_time}}</td><td>{{assert_word}}</td><td>
% if result == '失败':
<font color=red>
% end
{{result}}</td>
</tr>
% end
</table>
"""
html = template(template_demo, items=data)
with open(html_name+".html", 'wb') as f:
f.write(html.encode('utf-8')) if __name__ == '__main__':
data = [("API",'http://39.106.41.11:8080/register/', '{"username": "tiansl2831", "password": "wulaoshi123451", "email": "wulaoshi@qq.com"}', '{"username": "tiansl2831", "code": "01"}',"5ms","", '成功')]
html_name = '接口测试报告'
report_html(data,html_name)

20191011-构建我们公司自己的自动化接口测试框架-Util的htmlreport模块的更多相关文章

  1. 20191011-构建我们公司自己的自动化接口测试框架-Util的ClearData模块

    cleardata模块主要是用于在每次测试之前清除历史执行痕迹,主要代码如下: from Util.ParseExcel import * from ProVar.ProjConfigVar impo ...

  2. 20191011-构建我们公司自己的自动化接口测试框架-Util的AssertResult模块

    AssertResult主要就是进行结果断言的了,因为断言结果分2种情况,一种是断言词,一种是断言sheet,如果涉及断言sheet,则需要操作excel到对应的断言表断言所有的字段并且书写断言结果主 ...

  3. 20191011-构建我们公司自己的自动化接口测试框架-Util的TestDataHandler模块

    TestDataHandler模块主要是做测试数据的处理,包括转换数据格式和变量参数处理转换数据格式函数: data是数据,data以$()的方式识别变量,如果请求的数据有变量,则将变量用global ...

  4. 20191011-构建我们公司自己的自动化接口测试框架-Util的getTestSuite模块

    getTestSuite主要是用于在testData里面获取测试集以及对应的测试数据,包括2个主要的方法,一个是获取测试集,一个是获取测试集里面要执行的测试用例 获取测试集方法: from Util. ...

  5. 20191011-构建我们公司自己的自动化接口测试框架-Util的读取excel常用方法模块

    包括获取excel的sheet名字,设定excel的sheet,读excel,写excel等常规操作. from openpyxl import Workbook from openpyxl impo ...

  6. 20191011-构建我们公司自己的自动化接口测试框架-Action的request方法封装

    Action模块 封装接口request方法,根据传入的参数调用不同的请求方法,因为项目特色,我们公司的接口都是get和post方法,所以仅仅封装了get和post方法: import request ...

  7. 20191011-构建我们公司自己的自动化接口测试框架-testrun最重要的模块

    testrun模块呢就是最终自动化测试入口,调用前面封装的各个模块主要流程是: 1. 获取测试集种待执行的测试用例 2. 处理测试用例获取的数据,包括转换数据格式,处理数据的中的关联等 3. 处理完数 ...

  8. 20191011-构建我们公司自己的自动化接口测试框架-ProVar模块

    ProVar模块主要定义测试数据所在目录,以及定义变量和测试数据excel里面的column对应这样后续在进行excel操作的时候直接使用变量即可进行操作,后期excel的column有增删的时候,修 ...

  9. 20191011-构建我们公司自己的自动化接口测试框架-Config配置

    Config模块主要是为了存放的一些其他配置等的一个目录,当前目录存放日志配置文件 ################################################ [loggers] ...

随机推荐

  1. ElasticSearch java客户端更新时出现的错误:NoNodeAvailableException[None of the configured nodes are available

    下午尝试 用ElasticSearch  的java客户端去做数据检索工作,测试了一下批量更新,代码如下: public static void bulkUpdateGoods(List<Goo ...

  2. Fluent 时间步长【转载】

    转载自:http://blog.sina.com.cn/s/blog_4ada3be301011rjp.html 用FLUENT计算非稳态问题,是不是在计算时必须保证在每个时间步timestep里都要 ...

  3. scanf和fgets比较

    scanf 长度限制 #include<stdio.h> int main() { char food[5]; printf("Enter food"); scanf( ...

  4. RK3288 添加普通串口uart1和uart3

    CPU:RK3288 系统:Android 5.1 diff --git a/device/rockchip/common/init.connectivity.rc b/device/rockchip ...

  5. Postgresql修改字段的长度

    alter table tbl_exam alter column question type character varing(1000); alter table tbl_exam alter c ...

  6. mybatis的maven配置

    <!-- mybatis依赖--> <dependency> <groupId>org.mybatis</groupId> <artifactId ...

  7. C#中 Dictionary<>的使用及注意事项

    1,如果在主体代码中使用,直接在初始化中生成就行 2如果在其他层,比如逻辑层,要注意在事件内部定义,在外部的话,重复调用就会提示“”“已经定义了相同的KEY”,见例子 (例子是转的) Dictiona ...

  8. python 设计模式之迭代器模式

    #写在前面 真的有一大把年纪了,回头看看, 明明也很努力,却发现自己穷的一无所有,昨夜的事更是让我眼泪止不住的流,眼睛也肿了,委屈的愣是说不出一个字.前面荆棘丛生,身后已无退路,生活一地鸡毛,糟糕的一 ...

  9. android: requestLayout(), invalidate(), postInvalidate() 方法区别

    一.invalidate和postInvalidate 这两个方法都是在重绘当前控件的时候调用的.invalidate在UI线程中调用,postInvalidate在非UI线程中调用.因为androi ...

  10. Python检查数组元素是否存在类似PHPisset()方法

    Python检查数组元素是否存在类似PHP isset()方法 sset方法来检查数组元素是否存在,在Python中无对应函数,在Python中一般可以通过异常来处理数组元素不存在的情况,而无须事先检 ...