zoukankan      html  css  js  c++  java
  • 【selenium学习中级篇 -26】HTMLTestRunner生成测试报告

      新建文件夹test_report,在网上下载HTMLTestRunner.py文件放在Utils包中

    注意,如果你使用的是python 3.x的话,HTMLTestRunner.py文件也需要用python 3.x的

    接下来,我们改造TestRunner文件

    # coding=utf-8
    import unittest
    import Utils.HTMLTestRunner
    import os
    import time
    
    #设置报告文件保存路径
    report_path = os.path.dirname(os.path.abspath('.'))+'/test_report/'
    
    # 获取系统当前时间
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    
    #设置报告名称格式
    HtmlFile = report_path +now +"_TestReport.html"
    fp=open(HtmlFile,"wb")
    
    
    suite = unittest.TestLoader().discover("TestSuites")
    
    if __name__ == '__main__':
        runner = Utils.HTMLTestRunner.HTMLTestRunner(stream=fp,title="测试报告",description="用例情况")
        runner.run(suite)

    运行文件后,可以在test_report目录下,找到对应的测试报告文件

  • 相关阅读:
    使用RPC的接口创建账户同时购买内存并为其抵押CPU和NET资源
    使用RPC的接口创建账户
    【移动安全基础篇】——21、Android脱壳思路
    插件
    NGUI 优化
    影子
    优化文章索引
    MVC
    《你不常用的c#之XX》
    CMake
  • 原文地址:https://www.cnblogs.com/ronyjay/p/13024238.html
Copyright © 2011-2022 走看看