• Beautiful Report 异步并发测试html报告


    version_ :python3.7

    下载BeautifulReport   https://github.com/TesterlifeRaymond/BeautifulReport/archive/master.zip

    ,修改解压文件名称为BeautifulReport 丢进python 的site-packages

    pip3 install tomorrow

    安装异步tomorrow库,进入C:\Python37\Lib\site-packages\tomorrow\tomorrow.py修改异步函数名称以及调用函数名称为如下:

    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:
    run(i)

     放置test_case.py 到case后

     运行上述代码所在文件程序入口

    检查html报告效果:

  • 相关阅读:
    取时间
    DEV控件属性
    Dev之barManager控件属性
    linq查询Contains
    绑定
    运算符转换方法组和int类型的操作数
    学习计划实践
    学习计划2
    foreacht学习
    Spring5源码分析(二) IOC 容器的初始化(五)
  • 原文地址:https://www.cnblogs.com/SunshineKimi/p/10693481.html
Copyright © 2020-2023  润新知