首页 > Web开发 > 详细

【selenium学习中级篇 -26】HTMLTestRunner生成测试报告

时间:2020-06-01 12:27:06      阅读:53      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

  新建文件夹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目录下,找到对应的测试报告文件

技术分享图片

 

【selenium学习中级篇 -26】HTMLTestRunner生成测试报告

原文:https://www.cnblogs.com/ronyjay/p/13024238.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!