unittest多线程生成报告-----BeautifulReport
原文地址https://www.cnblogs.com/yoyoketang/p/8404204.html
前言
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就能下载到本地了
2.单个测试脚本test_a.py参考
# coding:utf-8import unittest from selenium import webdriver import timeclass Testaa(unittest.TestCase):u'''测试用例a的集合'''@classmethoddef 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.titleprint(t)self.assertIn("悠悠", t)def test_02(self):u'''用例2:用例2的操作步骤'''t = self.driver.titleprint(t)self.assertIn("悠悠", t)def test_03(self):u'''用例3:用例3的操作步骤'''t = self.driver.titleprint(t)self.assertIn("悠悠", t)@classmethoddef 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
BeautifulReport下载地址:https://pan.baidu.com/disk/home#/all?vmode=list&path=%2Fpython%E6%8E%A5%E5%8F%A3%E8%87%AA%E5%8A%A8%E5%8C%96--unittest--beautifulReport
转载于:https://www.cnblogs.com/111testing/p/10060900.html
unittest多线程生成报告-----BeautifulReport相关推荐
- HTMLTestRunner 为什么用PyCharm(Eclipse)执行测试成功但无法生成报告
在使用unittest+selenium进行自动化测试的时候,预期输出自动化测试报告,但是始终无法在指定package中输出report.html的报告.但是如果把生成report.html单独写进一 ...
- html 形成打印数据,用HTMLTestRunner生成报告,无法打印print的内容
我想既可以生成HTMLTestRunner测试报告,又可以在命令窗口print出文字来知晓当前脚本运行到具体哪一步. 可是没使用HTMLTestRunner生成报告的时候可以在命令窗口内打印print ...
- python中__init__.py的用法,执行指定的多个.py文件生成报告。简单粗暴1
这里以执行指定的多个test.py文件生成报告为例 __init__.py文件用于组织包(package). 简单来说,包是含有python模块的文件夹.一个python模块(module)为一个py ...
- 单元测试框架unittest和HtmlTestRunner报告
一.引入unittest单元测试框架的好处有: 提供用例组织与执行 提供丰富的断言方法 提供丰富的日志和报告(HTML格式的更好一些) 路径问题 在unittest中./表示首目录位置 TestCas ...
- python自动化测试生成报告_使用python测试框架完成自动化测试并生成报告-实例练习...
练习一: 使用unittest 完成自动化测试并使用HttpTestRunner生成报告 ''' 1.写个简单的计算器功能,大小写转换功能,随机生成字符串功能 2.编写测试用例,不同的数据(你能想到的 ...
- python测试脚本实例-使用python测试框架完成自动化测试并生成报告-实例练习
练习一: 使用unittest 完成自动化测试并使用HttpTestRunner生成报告 ''' 1.写个简单的计算器功能,大小写转换功能,随机生成字符串功能 2.编写测试用例,不同的数据(你能想到的 ...
- 【Python】Pandas profiling 生成报告并部署的一站式解决方案
Pandas 库功能非常强大,特别有助于数据分析与处理,并为几乎所有操作提供了完整的解决方案.一种常见的Pandas函数是pandas describe.它向用户提供数据集所有特征的描述性统计摘要,尽 ...
- php中如何调用datepicker,如何使用datepicker,ajax,php,mysql在两个日期之间生成报告?...
我被赋予了使用datepicker,ajax,php和mysql在两个给定日期之间生成报告的任务.以下是我的html: 日期明智的报告 From date: To date: User informa ...
- Pandas profiling 生成报告并部署的一站式解决方案
Pandas 库功能非常强大,特别有助于数据分析与处理,并为几乎所有操作提供了完整的解决方案.一种常见的Pandas函数是pandas describe.它向用户提供数据集所有特征的描述性统计摘要,尽 ...
最新文章
- 解除织梦dedeCMS标题/关键词/ 简略标题长度限制听语音
- Ubuntu下的固件分析Binwalk的安装
- ML二:NNSearch数据结构--二叉树
- 企业中squid+iptables多模块的综合应用案例
- CM: Relationship between Note created in Fiori UI and webclient UI
- Spring集成基础知识
- 【操作系统】进程调度的不同层次
- Serverless爆发,前端又一大利好消息
- 多站点IIS的架设:端口法
- seo代码优化工具_企业seo该怎么优化
- lodash 源码解读 _.findIndex(obj_array, fn)
- Windows2008 Server r2 64位显示桌面图标的方法
- 晨曦记账本如何将账本内容导出EXCEL表格
- 组合逻辑电路:一位全减器设计
- 微信小程序开发官方文档解读
- 玩转软路由 篇二:软路由中Esxi 7.0 安装教程和避坑指南
- SAP MM ME57 把PR转成PO
- 数学建模案例--基于微分方程的酒后驾车问题浅析
- 网络通信专题总结之OTA专题
- SAP术语总结详细版(转)
热门文章
- 转:C#动态循环生成button怎么分别写他们的事
- 计算机中的颜色XIII——颜色转换的快速计算公式
- 星际2的一些技术特性
- 利用正则表达式去掉html代码
- pip导包CalledProcessError: Command '('lsb_release', '-a')'异常处理
- STM32F407的时钟配置
- Dropbox用户数增速恢复:突破5亿 9个月增加1亿
- jsp/servlet学习笔记(核心编程)mysql部分
- 在Linux上编译安装php开发环境(install mysql5.6)-3
- Swift中的一致性哈希算法(补充)