import unittest
class TestCase01(unittest.TestCase):
@classmethod
def setUpClass(cls):
print(“case类开始执行”)
@classmethod
def tearDownClass(cls):
print(“case类结束执行”)
def test_06(self):
print("执行case06")
def test_01(self):
print("test01")
def test_02(self):
print("test02")
def test_03(self):
print("执行case03")
def test_04(self):
print("执行case04")
def test_05(self):
print("执行case05")
if name == “main”:
# unittest.main()
suite = unittest.TestSuite()
tests = [TestCase01(‘test_06’), TestCase01(‘test_02’), TestCase01(‘test_03’), TestCase01(‘test_05’),
TestCase01(‘test_01’)]
suite.addTests(tests)
runner = unittest.TextTestRunner()
runner.run(suite)
我的执行结果:
case类开始执行
test01
test02
执行case03
执行case04
执行case05
执行case06
case类结束执行