首页 > 其他分享 >ddt数据驱动最简单的应用二【多测师】

ddt数据驱动最简单的应用二【多测师】

时间:2022-10-26 12:34:16浏览次数:53  
标签:__ 多测师 htmlPath ddt run suite 驱动 def

import ddt
import unittest
from HTMLTestRunner_cn import HTMLTestRunner
import os
test_data=[1,2,3]


def run(value):

print(value)

def suites(testPath):
discover = unittest.defaultTestLoader.discover(testPath, pattern='test_ddtapi.py', top_level_dir=None)
return discover

def makeHtml(htmlPath,suite):
with open(htmlPath, 'wb') as f:
runner = HTMLTestRunner(stream=f, title="ddt report", description="测试报告:", verbosity=0,tester='多测师_王sir')
runner.run(suite)
def main():

testPath=os.getcwd()
suite=suites(testPath)
htmlPath=r'C:\Users\Administrator\lib\report\ddtTest.html'
makeHtml(htmlPath,suite)

@ddt.ddt
class TestDebug(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
@classmethod
def tearDownClass(cls):
pass

@ddt.data(*test_data)
def test_run(self,value):
run(value)

if __name__ == '__main__':
main()

 



标签:__,多测师,htmlPath,ddt,run,suite,驱动,def
From: https://blog.51cto.com/u_15846941/5797804

相关文章