unittest多线程生成报告(BeautifulReport)
前言
selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了。
环境必备:
- python3.6 : BeautifulReport不支持2.7
- tomorrow : pip install tomorrow安装
- BeautifulReport : github下载后放到/Lib/site-packages/目录下
BeautifulReport
1.BeautifulReport下载地址:BeautifulReport
2.下载方法:
- 方法一 会使用git的直接用git下载到本地
git clone https://github.com/TesterlifeRaymond/BeautifulReport
- 方法二 点Clone or Download按钮,Download ZIP就能下载到本地了
3.下载完之后,把BeautifulReport整个包放到python的/Lib/site-packages/目录下
使用方法
1.项目结构:
case test开头的.py用例脚本
report 放生成的html报告
run_all.py 用于执行全部脚本
2.单个测试脚本test_a.py参考
# coding:utf-8
import unittest
from selenium import webdriver
import time
class Testaa(unittest.TestCase):
u'''测试用例a的集合'''
@classmethod
def setUpClass(cls):
cls.driver = webdriver.Firefox()
def setUp(self):
self.driver.get("https://www.cnblogs.com/yoyoketang/")
def test_01(self):
u'''用例1:用例1的操作步骤'''
t = self.driver.title
print(t)
self.assertIn("悠悠", t)
def test_02(self):
u'''用例2:用例2的操作步骤'''
t = self.driver.title
print(t)
self.assertIn("悠悠", t)
def test_03(self):
u'''用例3:用例3的操作步骤'''
t = self.driver.title
print(t)
self.assertIn("悠悠", t)
@classmethod
def tearDownClass(cls):
cls.driver.quit()
if __name__ == "__main__":
unittest.main()
3.run_all代码
# coding=utf-8
import unittest
from BeautifulReport import BeautifulReport
import os
from tomorrow import threads
# 获取路径
curpath = os.path.dirname(os.path.realpath(__file__))
casepath = os.path.join(curpath, "case")
if not os.path.exists(casepath):
print("测试用例需放到‘case’文件目录下")
os.mkdir(casepath)
reportpath = os.path.join(curpath, "report")
if not os.path.exists(reportpath): os.mkdir(reportpath)
def add_case(case_path=casepath, rule="test*.py"):
'''加载所有的测试用例'''
discover = unittest.defaultTestLoader.discover(case_path,
pattern=rule,
top_level_dir=None)
return discover
@threads(3)
def run(test_suit):
result = BeautifulReport(test_suit)
result.report(filename='report.html', description='测试deafult报告', log_path='report')
if __name__ == "__main__":
# 用例集合
cases = add_case()
print(cases)
for i in cases:
print(i)
run(i)
4.报告效果图
备注:BeautifulReport是某大神在github分享的框架,这里借花献佛了,更多使用方法参考地址:https://github.com/TesterlifeRaymond/BeautifulReport
unittest多线程生成报告(BeautifulReport)的更多相关文章
- unittest多线程生成报告-----BeautifulReport
原文地址https://www.cnblogs.com/yoyoketang/p/8404204.html 前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点, ...
- selenium+python自动化91-unittest多线程生成报告(BeautifulReport)
前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...
- selenium+python-unittest多线程生成报告
前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...
- Python-Unittest多线程生成报告
前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...
- unittest自动化测试举例:自动读取ymal用例&调用接口并生成报告
用unittest框架写的接口自动化实现过程: 1.编写ymal格式用例: 2.导入ddt模块,该模块的主要功能是帮你读取ymal用例文件,自动获取内容并循环调用函数,具体见代码. 3.导入Beaut ...
- unittest框架,漂亮的报告BeautifulReport配置与错误截图详细解说
1.下载BeautifulReport模块 下载地址:https://github.com/TesterlifeRaymond/BeautifulReport 2.解压与存放路径 下载Beautifu ...
- 『心善渊』Selenium3.0基础 — 29、使用HTMLTestRunner生成unittest的HTML报告
目录 1.HTMLTestRunner介绍 2.HTMLTestRunner的使用 3.测试报告示例 4.封装成模块 1.HTMLTestRunner介绍 HTMLTestRunner是一个基于uni ...
- selenium,unittest——自动化执行多个py文件脚本并生成报告
将多个py文件的自动化脚本顺序运行,并生成报告,运行run_all_case后会自动运行文件内所有test开头的py文件并在指定文件夹report生成由脚本时间命名的报告 脚本执行后结果: 生成报告并 ...
- day11_单元测试_读取yaml文件中的用例,自动获取多个yaml文件内容执行生成报告
一.使用.yaml格式的文件直接可以存放字典类型数据,如下图,其中如果有-下一行有缩进代表这是个list,截图中是整体是一个list,其中有两部分,第二部分又包含另外一个list 二.单元测试:开发自 ...
随机推荐
- Palindromes in a Tree CodeForces - 914E
https://vjudge.net/problem/CodeForces-914E 点分就没一道不卡常的? 卡常记录: 1.把不知道为什么设的(unordered_map)s换成了(int[])s ...
- v-bind和v-on
v-bind指令用于设置HTML属性:v-bind:href 缩写为 :href <a :href="{{url}}">aa</a> v-on 指令用于绑 ...
- AJPFX关于Set接口学习笔记及总结
Set接口中的方法和Collection中方法一致的.Set接口取出方式只有一种,迭代器. |--HashSet:底层数据结构是哈希表,线程是不同步的.无序,高效: HashSet集合保证元素唯一性: ...
- postgresql 9.4.17 64位安装说明
本文在win 7 64位下安装postgresql 9.4.17 64位版,安装过程有录入项的界面都有截图 运行安装程序开始安装 开始时可能自动安装c++运行环境 然后正式开始安装 安装目录位置,不要 ...
- Js学习文件上传
// 文件上传 jQuery(function() { var $ = jQuery, $list = $('#thelist'), $btn = $('#ctlBtn'), state = 'pen ...
- Android(java)学习笔记169:服务(service)之为什么使用服务
1.服务 service 长期在后台运行的进程,一般没有应用程序界面 2.进程线程和应用程序之间的关系 应用程序开启,系统启动一个Linux进程,所有的组件都是运行在同一个进程的同一个线程(mai ...
- mysql 中modify和change区别(以及使用modify修改字段名称报错)
使用modify修改字段报错如下: mysql> alter table student modify name sname char(16);ERROR 1064 (42000): You h ...
- 骑芯供应链(T 面试)
1.目前市面上主流的团队开发模式是什么? 正解:DevOps,https://blog.csdn.net/bntX2jSQfEHy7/article/details/79168865 2.你觉得什么是 ...
- df - 报告文件系统磁盘空间的使用情况
总览 df [OPTION]... [FILE]... POSIX 选项: [-kP] GNU 选项 (最短方式): [-ahHiklmPv] [-t fstype] [-x fstype] [--b ...
- Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/config/spring/applicationContext.xml]
在搭建SpringMVC框架的时候遇到了这个问题 问题的原因: 就是没有找到applicatoincontext.xml这个文件, 因为idea自动生成的路径不正确 因此需要再web.xml里面, ( ...