原文地址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-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

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

unittest多线程生成报告-----BeautifulReport的更多相关文章

  1. unittest多线程生成报告(BeautifulReport)

    前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...

  2. selenium+python自动化91-unittest多线程生成报告(BeautifulReport)

    前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...

  3. selenium+python-unittest多线程生成报告

    前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...

  4. Python-Unittest多线程生成报告

    前言 selenium多线程跑用例,这个前面一篇已经解决了,如何生成一个测试报告这个是难点,刚好在github上有个大神分享了BeautifulReport,完美的结合起来,就能生成报告了. 环境必备 ...

  5. unittest自动化测试举例:自动读取ymal用例&调用接口并生成报告

    用unittest框架写的接口自动化实现过程: 1.编写ymal格式用例: 2.导入ddt模块,该模块的主要功能是帮你读取ymal用例文件,自动获取内容并循环调用函数,具体见代码. 3.导入Beaut ...

  6. unittest框架,漂亮的报告BeautifulReport配置与错误截图详细解说

    1.下载BeautifulReport模块 下载地址:https://github.com/TesterlifeRaymond/BeautifulReport 2.解压与存放路径 下载Beautifu ...

  7. 『心善渊』Selenium3.0基础 — 29、使用HTMLTestRunner生成unittest的HTML报告

    目录 1.HTMLTestRunner介绍 2.HTMLTestRunner的使用 3.测试报告示例 4.封装成模块 1.HTMLTestRunner介绍 HTMLTestRunner是一个基于uni ...

  8. selenium,unittest——自动化执行多个py文件脚本并生成报告

    将多个py文件的自动化脚本顺序运行,并生成报告,运行run_all_case后会自动运行文件内所有test开头的py文件并在指定文件夹report生成由脚本时间命名的报告 脚本执行后结果: 生成报告并 ...

  9. day11_单元测试_读取yaml文件中的用例,自动获取多个yaml文件内容执行生成报告

    一.使用.yaml格式的文件直接可以存放字典类型数据,如下图,其中如果有-下一行有缩进代表这是个list,截图中是整体是一个list,其中有两部分,第二部分又包含另外一个list 二.单元测试:开发自 ...

随机推荐

  1. MySQL主从同步添加至zabbix监控

    参考文档:https://blog.csdn.net/hellowidow_2020/article/details/78985368    https://www.cnblogs.com/cdjia ...

  2. npm构建保存 code ELIFECYCLE解决办法

    参考文档https://blog.csdn.net/gh254172840/article/details/78871573 使用npm构建报错 解决办法,进入工作目录 rm -rf node_mod ...

  3. Mac上的jdk

    最近装jdk从网上找到的资料: 一.以前版本的Mac自带了的JDK6,安装在目录:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/下.* JDK7 ...

  4. 移位运算符:<<,>>,>>>总结

    位移总结篇:带demo讲解 https://www.cnblogs.com/yyangblog/archive/2011/01/14/1935656.html

  5. Warning: Failed to halt at after bootloader, forced stop at

    该错误证实是因为 cc2650 SW下载模式,芯片复位引脚未接出来导致,芯片复位必须和下载器保持良好连接

  6. 命令配置linux分辨率

    1. xrandr 使用该命令列举系统支持的分辨率 2. xrandr -s 回复原来的分辨率 3. xrandr -s 1360x768 设置分辨率   如果分辨率没能锁定,请在根目录使用gedit ...

  7. UDP,TCP的套接字编程的Python实现

    UDP,TCP的套接字编程的Python实现 套接字:连接应用层和运输层,应用层的网络应用程序使用IP地址+端口号来标识自己,然后通过套接字调用运输层为其服务,网络应用程序只能指定自己要使用的网络类型 ...

  8. base64简单使用

    加密: import base64 import random str ="aqwertyuiopasdfghjklzxcvbnm963.0852741,.;'" a = '人生苦 ...

  9. vue项目使用vue-photo-preview插件实现点击图片放大预览和移动

    官方链接: http://npm.taobao.org/package/vue-photo-preview # 安装 npm install vue-photo-preview --save # 引入 ...

  10. Python中的下划线(转)

    译文原文:https://segmentfault.com/a/1190000002611411 原文地址这篇文章讨论Python中下划线_的使用.跟Python中很多用法类似,下划线_的不同用法绝大 ...