Unittest方法 -- 测试套件

TestSuite 测试固件

一、

import unittest

class F6(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_001(self):
pass

def test_002(self):
pass

if __name__ == '__main__':
"""使用套件 Makesuite 可以执行F6类的所有执行用例"""
suite = unittest.TestSuite(unittest.makeSuite(F6))
unittest.TextTestRunner(verbosity=2).run()

二、
import unittest

class Baidu_Test(unittest.TestCase):

@classmethod
def setUpClass(cls):
pass

@classmethod
def tearDownClass(cls):
pass

def test_baidu_news(self):
pass

def test_baidu_map(self):
pass

if __name__ == '__main__':

"""测试套件suite,1、分别测试Baidu_Test类的方法;2、可直接执行Baidu_Test类"""
suite = unittest.TestSuite()
suite.addTest(Baidu_Test())
# suite.addTest(Baidu_Test("test_baidu_news"))
# suite.addTest(Baidu_Test("test_baidu_map"))
unittest.TextTestRunner(verbosity=2).run(suite)


posted @ 2019-07-14 11:10  Test挖掘者  阅读(684)  评论(0编辑  收藏  举报