GithubHelp home page GithubHelp logo

beautifulreport's Introduction

项目年久失修, 有问题可以直接联系作者

qq: 58558327

BeautifulReport


适用于unittest自动化测试的可视化报告

这是什么报告?


这是unittest自动化测试报告的生成packages

这是一个基于unittest.TestReport模块实现的测试用例模板, 可以把我们每次测试中的结果通过BeautifulReport整合成一个可视化的报表.

如何使用它?

>>> git clone https://github.com/TesterlifeRaymond/BeautifulReport
>>> cp -R BeautifulReport to/python/site-packages/

可以直接在sample路径直接运行

>>> python sample.py

import unittest
from BeautifulReport import BeautifulReport

if __name__ == '__main__':
    test_suite = unittest.defaultTestLoader.discover('../tests', pattern='test*.py')
    result = BeautifulReport(test_suite)
    result.report(filename='测试报告', description='测试deafult报告', log_path='report')

Report API简介

  • BeautifulReport.report

    • report ( filename -> 测试报告名称, 如果不指定默认文件名为report.html description -> 测试报告用例名称展示 log_path='.' -> log文件写入路径 )
  • BeautifulReport.add_test_img

如果使用报告过程中需要把测试报告的截图放在报告中, 可以使用add_test_img方法

  • add_test_img ( *pargs )

可以在测试用例上挂载一个装饰器, 实例内容如下

ps:

  • 默认存放的图片路径是img, 需要在当前测试项目的启动路径下, 创建一个img文件夹
  • 传递给装饰器的图片,在运行测试前可以不存在, 运行测试之后生成即可.
  • 当文件在报告中展示后, 想要看到原图, 可以点击报告中的缩略图查看完整的截图
import unittest
from BeautifulReport import BeautifulReport


class UnittestCaseSecond(unittest.TestCase):
    """ 测试代码生成与loader 测试数据"""
    
    def test_equal(self):
        """
            test 1==1
        :return:
        """
        import time
        time.sleep(1)
        self.assertTrue(1 == 1)
    
    @BeautifulReport.add_test_img('测试报告.png')
    def test_is_none(self):
        """
            test None object
        :return:
        """
        save_some_img('测试报告.png')
        self.assertIsNone(None)
  • 运行sample之后生成如下报告

测试报告

鸣谢:

再见理想-飞哥 提供的HTML实现, 及Java数据展示的实现部分, 如果是Java同学请移步

beautifulreport's People

Contributors

autophyte avatar gcanoxl avatar nhycraymond avatar steinvenic avatar testerliferaymond avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beautifulreport's Issues

请教下关于生成的报告

suite = unittest.TestSuite() # 建立测试集合
all_cases = unittest.defaultTestLoader.discover('./tests', 'test_*.py')
for case in all_cases:
run = BeautifulReport(case)
time.sleep(1)
run.report(filename="%s_report.html" % time.strftime('%Y%m%d%H%M%S'), description='自动化测试报告',log_path='./report')

我是这样写的,比如我tests目录下有两个测试类,这样虽然可以生成两个测试报告,但是,最后一个测试报告,还是会把两个类放在一个报告里面。

你好,目前使用chrome的handless配置回报一个NoneType的错误,使用有界面的就不会,不知道大家有遇到过么

这个是driver配置
def hanless_chrome(self):
opt = Options()
opt.add_argument('--no-sandbox') # 解决DevToolsActivePort文件不存在的报错
opt.add_argument('window-size=1920x3000') # 指定浏览器分辨率
opt.add_argument('--disable-gpu') # 谷歌文档提到需要加上这个属性来规避bug
opt.add_argument('--hide-scrollbars') # 隐藏滚动条, 应对一些特殊页面
opt.add_argument('blink-settings=imagesEnabled=false') # 不加载图片, 提升速度
opt.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=opt)
return driver
image
主文件BeautifulReport的189行outputBuffer这个值是个NoneType类型所以找不到getValue的方法
请指教

修改template 不生效?

我修改了template里的中文,因为我们的report是给洋人看的,但是我修改了所有template的中文再次生成报告,为什么还是中文?

报告汇总bug

报告汇总:用例通过的数和用例跳过的数显示跟详细数据中的计数不一致;望大佬修复!!!

路径不对

FileNotFoundError: [Errno 2] No such file or directory: 'C:\Python35\Lib\site-packages/BeautifulReport/template/template'
这怎么搞,为什么总是报错这个

import error

请问怎么解决。
python:3.4.4
widows 10.

Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

from BeautifulReport import BeautifulReport as bf
Traceback (most recent call last):
File "", line 1, in
File "C:\Python34\lib\site-packages\BeautifulReport_init_.py", line 8, in
from .BeautifulReport import BeautifulReport
File "C:\Python34\lib\site-packages\BeautifulReport\BeautifulReport.py", line 398
**json.load(theme),
^
SyntaxError: invalid syntax

如何实现,想要显示的内容添加到报告中

try:
# 启动浏览器,访问首页
daima_Page.gotoP1()

        # 输入名字
        daima_Page.input_name_text()

        #输入手机号
        daima_Page.input_mobile_text()

        #点选出生日期
        daima_Page.click_date_choose()
        daima_Page.click_birth_choose()

        #点击马上贷款
        daima_Page.click_loan_input()
    except:
        print("需手工验证地址:%s" % url)

实际情况:打开多个URL,输入内容。有的URL无法输入内容跳过执行后,打印出URL地址来。
想要实现:想要把打印出来的URL显示在报告内,我要如何实现呢?

是否支持python+unittest的assert断言?

self.assertEqual(input_Page.get_title(), Daima_title)
我尝试了断言,但报告中没有打印内容。
想问,如何写断言才能让断言结果内容显示在报告中

请教,直接运行sample.py报错。

主要报错信息:
File "G:\BeautifulReport\BeautifulReport.py", line 189, in complete_output
return self.outputBuffer.getvalue()
AttributeError: 'NoneType' object has no attribute 'getvalue'
即:
if self.sys_stdout:
sys.stdout = self.sys_stdout
sys.stderr = self.sys_stderr
self.sys_stdout = None
self.sys_stderr = None
return self.outputBuffer.getvalue()
self.sys_stdout为None,
self.outputBuffer也为None,请指教,谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.