html测试报告,4.测试报告HTMLTestRunner

8bffc62de70a

我们先下载对应的模块到我们的目录下

8bffc62de70a

(venv是python的虚拟环境,这个可有可无)

使用HTMLTestRunner

我们在项目里新建一个用来放测试用例的文件夹testCase,把我们之前的登录测试移动到该文件夹里并重命名为test_login.py。

在项目目录里新建runner.py文件:

#coding=utf-8

from HTMLTestReportCN import HTMLTestReportCN

import unittest

import time

casefile = "./testCase/"

#遍历testCase里的所有test_*.py文件,添加所有测试用例。

def createsuite():

testunit = unittest.TestSuite()

discover = unittest.defaultTestLoader.discover(casefile,pattern='test_*.py',top_level_dir=None)

for test_suite in discover:

for test_case in test_suite:

testunit.addTests(test_case)

return testunit

now = time.strftime("%Y-%m-%d_%H%M",time.localtime())

#测试报告存放的位置

filepath = './result/report/' + now +'.html'

fp = open(filepath,'wb')

runner = HTMLTestReportCN.HTMLTestRunner(

stream=fp,

title='自动化报告',

tester='lin'

)

runner.run(createsuite())

fp.close()

并手动新建./result/report/文件夹

8bffc62de70a

项目目录

在终端cd到项目目录,输入python runner.py

(venv) yauloladeMacBook-Air:appium yaulola$ python runner.py

.

Time Elapsed: 0:00:43.602967

(venv) yauloladeMacBook-Air:appium y

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值