github源码下载地址:https://github.com/huilansame/HTMLTestRunner_PY3/archive/master.zip

解压后进入文件找到文件:HTMLTestRunner_PY3.py,将其放入C:\Python37\Lib\site-packages 内

代码演示调用以及报告效果,自己使用随意写代码此处只是随便写了个

 



import ddt
import unittest
from HTMLTestRunner_PY3 import HTMLTestRunner
import random
import string
import time

def suiteList(testPath):
discover = unittest.defaultTestLoader.discover(testPath, pattern='test*.py', top_level_dir=None)
List=[suite for suite in discover]

return List


def run(suite,htmlPath):
with open(htmlPath, 'wb') as f:
runner = HTMLTestRunner(stream=f, title="ddt report", description="测试报告:", verbosity=2)
runner.run(suite)


def randDigit():
stamp=str(int(time.time()*1000000))
# list= random.sample(string.digits,random.randint(4,5))
# res=''.join(list)+"_"+stamp
return stamp


@ddt.ddt
class Test(unittest.TestCase):
test_data=suiteList(testPath=r'./')

@classmethod
def setUpClass(cls):
pass
@classmethod
def tearDownClass(cls):
pass

@ddt.data(*test_data)
def test_run(self,value):
run(value,htmlPath=r'./{}report.html'.format(randDigit()))
print(time.asctime())
if __name__ == '__main__':
unittest.main()

 缺陷分析在于失败无截图,unittest不能重跑失败用例

转载于:https://www.cnblogs.com/SunshineKimi/p/10693511.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐