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)